Sirikata
Classes | Public Member Functions | Protected Member Functions | Private Types | Private Attributes
Sirikata::Transfer::MemoryCacheLayer Class Reference

MemoryCacheLayer is usually the first layer in the cache--simple map from FileId to SparseData. More...

#include <MemoryCacheLayer.hpp>

Inheritance diagram for Sirikata::Transfer::MemoryCacheLayer:
Collaboration diagram for Sirikata::Transfer::MemoryCacheLayer:

List of all members.

Classes

struct  CacheData

Public Member Functions

 MemoryCacheLayer (CachePolicy *policy, CacheLayer *tryNext)
virtual void purgeFromCache (const Fingerprint &fileId)
 Purges this hash from all subsequent caches.
virtual void getData (const Fingerprint &fileId, const Range &requestedRange, const TransferCallback &callback)
 Query this cache layer.

Protected Member Functions

virtual void populateCache (const Fingerprint &fileId, const DenseDataPtr &respondData)
 Goes up the heirararchy of cache layers filling in data.
virtual void destroyCacheEntry (const Fingerprint &fileId, CacheEntry *cacheLayerData, cache_usize_type releaseSize)
 Called after a cache entry has been destroyed-- Does not remove the item from other caches in the chain.

Private Types

typedef CacheMap MemoryMap

Private Attributes

MemoryMap mData

Detailed Description

MemoryCacheLayer is usually the first layer in the cache--simple map from FileId to SparseData.


Member Typedef Documentation


Constructor & Destructor Documentation

Sirikata::Transfer::MemoryCacheLayer::MemoryCacheLayer ( CachePolicy policy,
CacheLayer tryNext 
) [inline]

Member Function Documentation

virtual void Sirikata::Transfer::MemoryCacheLayer::destroyCacheEntry ( const Fingerprint fileId,
CacheEntry cacheLayerData,
cache_usize_type  releaseSize 
) [inline, protected, virtual]

Called after a cache entry has been destroyed-- Does not remove the item from other caches in the chain.

Should be called only from CacheMap.

Reimplemented from Sirikata::Transfer::CacheLayer.

virtual void Sirikata::Transfer::MemoryCacheLayer::getData ( const Fingerprint fileId,
const Range requestedRange,
const TransferCallback callback 
) [inline, virtual]

Query this cache layer.

If successful, call callback with the data and also call populateCache in order to populate the previous cache levels.

Parameters:
fidA unique identifier corresponding to the file (contains a hash).
requestedRangeA Range object specifying a single range that you need.
callbackTo be called with the data if successful, or NULL if failed.
Returns:
false, if the callback happened synchronously (i.e. in memory cache)

Reimplemented from Sirikata::Transfer::CacheLayer.

References Sirikata::Transfer::DenseDataList::contains(), Sirikata::Logging::detailed, Sirikata::Transfer::CacheMap::read_iterator::find(), mData, Sirikata::Transfer::MemoryCacheLayer::CacheData::mSparse, Sirikata::Transfer::CacheLayer::populateParentCaches(), Sirikata::Transfer::Range::printRangeList(), SILOG, and SILOGP.

virtual void Sirikata::Transfer::MemoryCacheLayer::populateCache ( const Fingerprint fileId,
const DenseDataPtr data 
) [inline, protected, virtual]
virtual void Sirikata::Transfer::MemoryCacheLayer::purgeFromCache ( const Fingerprint fileId) [inline, virtual]

Purges this hash from all subsequent caches.

In general, it is not useful to do this manually, since the CachePolicy handles freeing extra data, and it is usually assumed that the cache is correct.

Validity checking should probably be added elsewhere--though it is not really feasable for incomplete downloads if we used a range.

Reimplemented from Sirikata::Transfer::CacheLayer.

References Sirikata::Transfer::CacheMap::write_iterator::erase(), Sirikata::Transfer::CacheMap::write_iterator::find(), and mData.


Member Data Documentation


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