#include <MemStore.h>

Inheritance diagram for MemStore:
Collaboration diagram for MemStore:


class  SlotAndPage
 temporary storage for slot and page ID pointers; for the waiting cache More...

Public Member Functions

 MemStore ()
virtual ~MemStore ()
bool keepInLocalMemory (const StoreEntry &e) const
 whether e should be kept in local RAM for possible future caching More...
void write (StoreEntry &e)
 copy non-shared entry data of the being-cached entry to our cache More...
void completeWriting (StoreEntry &e)
 all data has been received; there will be no more write() calls More...
void disconnect (StoreEntry &e)
 called when the entry is about to forget its association with mem cache More...
virtual void create () override
 create system resources needed for this store to operate in the future More...
virtual void init () override
virtual StoreEntryget (const cache_key *) override
 Retrieve a store entry from the store (blocking) More...
virtual uint64_t maxSize () const override
virtual uint64_t minSize () const override
 the minimum size the store will shrink to via normal housekeeping More...
virtual uint64_t currentSize () const override
 current size More...
virtual uint64_t currentCount () const override
 the total number of objects stored right now More...
virtual int64_t maxObjectSize () const override
 the maximum size of a storable object; -1 if unlimited More...
virtual void getStats (StoreInfoStats &stats) const override
 collect statistics More...
virtual void stat (StoreEntry &e) const override
virtual void reference (StoreEntry &e) override
 somebody needs this entry (many cache replacement policies need to know) More...
virtual bool dereference (StoreEntry &e) override
virtual void updateHeaders (StoreEntry *e) override
 make stored metadata and HTTP headers the same as in the given entry More...
virtual void maintain () override
 perform regular periodic maintenance; TODO: move to UFSSwapDir::Maintain More...
virtual bool anchorCollapsed (StoreEntry &e, bool &inSync) override
virtual bool updateCollapsed (StoreEntry &e) override
virtual void markForUnlink (StoreEntry &) override
 expect an unlink() call after the entry becomes idle More...
virtual void unlink (StoreEntry &e) override
 remove the entry from the store More...
virtual bool smpAware () const override
virtual int callback ()
 called once every main loop iteration; TODO: Move to UFS code. More...
virtual void sync ()
 prepare for shutdown More...

Static Public Member Functions

static int64_t EntryLimit ()
 calculates maximum number of entries we need to store and map More...

Protected Member Functions

bool shouldCache (StoreEntry &e) const
 whether we should cache the entry More...
bool startCaching (StoreEntry &e)
 locks map anchor and preps to store the entry in shared memory More...
void copyToShm (StoreEntry &e)
 copies all local data to shared memory More...
void copyToShmSlice (StoreEntry &e, Ipc::StoreMapAnchor &anchor, Ipc::StoreMap::Slice &slice)
 copies at most one slice worth of local memory to shared memory More...
bool copyFromShm (StoreEntry &e, const sfileno index, const Ipc::StoreMapAnchor &anchor)
 copies the entire entry from shared to local memory More...
bool copyFromShmSlice (StoreEntry &e, const StoreIOBuffer &buf, bool eof)
 imports one shared memory slice into local memory More...
void updateHeadersOrThrow (Ipc::StoreMapUpdate &update)
void anchorEntry (StoreEntry &e, const sfileno index, const Ipc::StoreMapAnchor &anchor)
 anchors StoreEntry to an already locked map entry More...
bool updateCollapsedWith (StoreEntry &collapsed, const sfileno index, const Ipc::StoreMapAnchor &anchor)
 updates collapsed entry after its anchor has been located More...
Ipc::Mem::PageId pageForSlice (Ipc::StoreMapSliceId sliceId)
 safely returns a previously allocated memory page for the given entry slice More...
Ipc::StoreMap::SlicenextAppendableSlice (const sfileno entryIndex, sfileno &sliceOffset)
sfileno reserveSapForWriting (Ipc::Mem::PageId &page)
 finds a slot and a free page to fill or throws More...
virtual void noteFreeMapSlice (const Ipc::StoreMapSliceId sliceId) override
 adjust slice-linked state before a locked Readable slice is erased More...

Protected Attributes

friend ShmWriter

Private Types

typedef MemStoreMapExtras Extras

Private Attributes

< Ipc::Mem::PageStack
 unused map slot IDs More...
 index of mem-cached entries More...
Ipc::Mem::Pointer< Extrasextras
 IDs of pages with slice data. More...
sfileno lastWritingSlice
 the last allocate slice for writing a store entry (during copyToShm) More...
SlotAndPage waitingFor
 a cache for a single "hot" free slot and page More...

Detailed Description

Stores HTTP entities in RAM. Current implementation uses shared memory. Unlike a disk store (SwapDir), operations are synchronous (and fast).

Definition at line 29 of file MemStore.h.

Member Typedef Documentation

Definition at line 98 of file MemStore.h.

Constructor & Destructor Documentation

MemStore::MemStore ( )

Definition at line 170 of file MemStore.cc.

MemStore::~MemStore ( )

Definition at line 174 of file MemStore.cc.

References map.

Member Function Documentation

bool MemStore::anchorCollapsed ( StoreEntry ,
bool &   

If this storage cannot cache collapsed entries, return false. If the entry is not found, return false. Otherwise, return true after tying the entry to this cache and setting inSync to updateCollapsed().

Reimplemented from Store::Controlled.

Definition at line 406 of file MemStore.cc.

References anchorEntry(), hash_link::key, map, Ipc::StoreMap::openForReading(), and updateCollapsedWith().

virtual int Store::Storage::callback ( )

Reimplemented in Fs::Ufs::UFSSwapDir, TestStore, Store::Controller, and Store::Disks.

Definition at line 70 of file Storage.h.

virtual void MemStore::create ( )

Implements Store::Storage.

Definition at line 48 of file MemStore.h.

uint64_t MemStore::currentCount ( ) const

Implements Store::Storage.

Definition at line 286 of file MemStore.cc.

References Ipc::StoreMap::entryCount(), and map.

Referenced by getStats(), and stat().

uint64_t MemStore::currentSize ( ) const

Implements Store::Storage.

Definition at line 279 of file MemStore.cc.

References Ipc::Mem::PageId::cachePage, Ipc::Mem::PageLevel(), and Ipc::Mem::PageSize().

Referenced by stat().

bool MemStore::dereference ( StoreEntry e)

somebody no longer needs this entry (usually after calling reference()) return false iff the idle entry should be destroyed

Implements Store::Controlled.

Definition at line 303 of file MemStore.cc.

int64_t MemStore::EntryLimit ( )
void MemStore::init ( )

Start preparing the store for use. To check readiness, callers should use readable() and writable() methods.

Implements Store::Storage.

Definition at line 180 of file MemStore.cc.

References SquidConfig::cacheSwap, Ipc::StoreMap::cleaner, Config, DBG_IMPORTANT, debugs, EntryLimit(), extras, ExtrasLabel, freeSlots, map, MapLabel, Store::Controller::maxObjectSize(), maxObjectSize(), Must, Store::DiskConfig::n_configured, Store::Root(), shm_old, and SpaceLabel.

Referenced by Store::Controller::init().

bool MemStore::keepInLocalMemory ( const StoreEntry e) const
void MemStore::maintain ( )

Implements Store::Storage.

Definition at line 262 of file MemStore.cc.

void MemStore::markForUnlink ( StoreEntry e)
int64_t MemStore::maxObjectSize ( ) const

Implements Store::Storage.

Definition at line 292 of file MemStore.cc.

References Config, SquidConfig::maxInMemObjSize, SquidConfig::memMaxSize, min(), and SquidConfig::Store.

Referenced by copyToShm(), init(), and shouldCache().

uint64_t MemStore::maxSize ( ) const

The maximum size the store will support in normal use. Inaccuracy is permitted, but may throw estimates for memory etc out of whack.

Implements Store::Storage.

Definition at line 273 of file MemStore.cc.

References Config, and SquidConfig::memMaxSize.

Referenced by stat().

uint64_t MemStore::minSize ( ) const

Implements Store::Storage.

Definition at line 267 of file MemStore.cc.

Ipc::StoreMap::Slice & MemStore::nextAppendableSlice ( const sfileno  fileNo,
sfileno sliceOffset 

starts checking with the entry chain slice at a given offset and returns a not-full (but not necessarily empty) slice, updating sliceOffset

Definition at line 752 of file MemStore.cc.

References debugs, extras, map, Must, Ipc::StoreMapSlice::next, Ipc::Mem::PageSize(), reserveSapForWriting(), Ipc::StoreMapSlice::size, Ipc::StoreMapAnchor::start, Ipc::StoreMap::writeableEntry(), and Ipc::StoreMap::writeableSlice().

Referenced by ShmWriter::copyToShm(), and copyToShm().

Ipc::Mem::PageId MemStore::pageForSlice ( Ipc::StoreMapSliceId  sliceId)

Definition at line 788 of file MemStore.cc.

References extras, and Must.

Referenced by ShmWriter::copyToShmSlice(), and copyToShmSlice().

void MemStore::reference ( StoreEntry e)

Implements Store::Controlled.

Definition at line 298 of file MemStore.cc.

virtual bool MemStore::smpAware ( ) const

whether this storage is capable of serving multiple workers; a true result does not imply [lack of] non-SMP support because [only] some SMP-aware storages also support non-SMP configss

Implements Store::Storage.

Definition at line 66 of file MemStore.h.

void MemStore::stat ( StoreEntry e) const
virtual void Store::Storage::sync ( void  )

Reimplemented in Fs::Ufs::UFSSwapDir, Store::Controller, and Store::Disks.

Definition at line 76 of file Storage.h.

bool MemStore::updateCollapsed ( StoreEntry )

Update a local collapsed entry with fresh info from this cache (if any). Return true iff the cache supports collapsed entries and the given local collapsed entry is now in sync with this storage.

Reimplemented from Store::Controlled.

Definition at line 423 of file MemStore.cc.

References assert, MemObject::MemCache::index, map, StoreEntry::mem_obj, MemObject::memCache, Ipc::StoreMap::readableEntry(), and updateCollapsedWith().

bool MemStore::updateCollapsedWith ( StoreEntry collapsed,
const sfileno  index,
const Ipc::StoreMapAnchor anchor 
void MemStore::updateHeaders ( StoreEntry )

Member Data Documentation

Ipc::Mem::Pointer<Extras> MemStore::extras
Ipc::Mem::Pointer<Ipc::Mem::PageStack> MemStore::freeSlots

Definition at line 95 of file MemStore.h.

Referenced by init(), noteFreeMapSlice(), and reserveSapForWriting().

sfileno MemStore::lastWritingSlice

Definition at line 102 of file MemStore.h.

Referenced by copyToShm(), and copyToShmSlice().

friend MemStore::ShmWriter

Definition at line 71 of file MemStore.h.

SlotAndPage MemStore::waitingFor

Definition at line 113 of file MemStore.h.

Referenced by noteFreeMapSlice(), and reserveSapForWriting().

The documentation for this class was generated from the following files:






Web Site Translations