#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
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 anchorToCache (StoreEntry &e, bool &inSync) override
virtual bool updateAnchored (StoreEntry &) override
virtual void evictCached (StoreEntry &) override
virtual void evictIfFound (const cache_key *) override
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 updateAnchoredWith (StoreEntry &, const sfileno, const Ipc::StoreMapAnchor &)
 updates Transients 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::anchorToCache ( StoreEntry ,
bool &   

If Transients entry cannot be attached to this storage, return false. If the entry is not found, return false. Otherwise, return true after tying the entry to this cache and setting inSync to updateAnchored().

Reimplemented from Store::Controlled.

Definition at line 405 of file MemStore.cc.

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

virtual int Store::Storage::callback ( )

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

Definition at line 72 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::evictCached ( StoreEntry e)

Prevent new get() calls from returning the matching entry. If the matching entry is unused, it may be removed from the store now. The store entry is matched using either e attachment info or e.key.

Implements Store::Storage.

Definition at line 896 of file MemStore.cc.

References CollapsedForwarding::Broadcast(), debugs, StoreEntry::destroyMemObject(), disconnect(), evictIfFound(), Ipc::StoreMap::freeEntry(), StoreEntry::hasMemStore(), MemObject::MemCache::index, StoreEntry::locked(), map, StoreEntry::mem_obj, MemObject::memCache, and StoreEntry::publicKey().

void MemStore::evictIfFound ( const cache_key )

An evictCached() equivalent for callers that did not get() a StoreEntry. Callers with StoreEntry objects must use evictCached() instead.

Implements Store::Storage.

Definition at line 915 of file MemStore.cc.

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

Referenced by evictCached().

StoreEntry * MemStore::get ( const cache_key )
a possibly unlocked/unregistered stored entry with key (or nil) The returned entry might not match the caller's Store ID or method. The caller must abandon()/release() the entry or register it with Root(). This method must not trigger slow I/O operations (e.g., disk swap in).

Implements Store::Controlled.

Definition at line 310 of file MemStore.cc.

References anchorEntry(), copyFromShm(), StoreEntry::createMemObject(), debugs, destroyStoreEntry, Ipc::StoreMap::freeEntry(), map, NULL, and Ipc::StoreMap::openForReading().

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.

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 735 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 771 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 78 of file Storage.h.

bool MemStore::updateAnchored ( StoreEntry )

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

Reimplemented from Store::Controlled.

Definition at line 422 of file MemStore.cc.

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

bool MemStore::updateAnchoredWith ( StoreEntry entry,
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