NCBI C++ ToolKit
|
Search Toolkit Book for ICache
BLOB cache read/write/maintenance interface. More...
#include <util/cache/icache.hpp>
Classes | |
struct | SBlobAccessDescr |
BLOB access descriptor. More... | |
Public Types | |
enum | EFlags { fBestPerformance = (0 << 0) , fBestReliability = (1 << 0) } |
Flags for the underlying storage. More... | |
enum | ETimeStampFlags { fNoTimeStamp = 0 , fTimeStampOnCreate = (1 << 0) , fTimeStampOnRead = (1 << 1) , fTrackSubKey = (1 << 2) , fExpireLeastFrequentlyUsed = (1 << 3) , fPurgeOnStartup = (1 << 4) , fCheckExpirationAlways = (1 << 5) } |
ICache keeps timestamps of every cache entry. More... | |
enum | EKeepVersions { eKeepAll , eDropOlder , eDropAll } |
If to keep already cached versions of the BLOB when storing another version of it (not necessarily a newer one) More... | |
enum | EBlobVersionValidity { eCurrent , eExpired , eValid = eCurrent } |
BLOB version existence and validity – from the point of view of the underlying cache implementation. More... | |
typedef int | TBlobVersion |
typedef int | TFlags |
Bitwise OR of "EFlags" flags. More... | |
typedef ETimeStampFlags | ETimeStampPolicy |
typedef int | TTimeStampFlags |
Holds a bitwise OR of "ETimeStampFlags". More... | |
typedef EBlobVersionValidity | EBlobValidity |
Backward-compatibility typedef. More... | |
typedef TPluginManagerParamTree | TCacheParams |
Key values to search for a cache with given params. More... | |
Public Member Functions | |
virtual TFlags | GetFlags ()=0 |
Retrieve the effective combination of flags from the underlying storage. More... | |
virtual void | SetFlags (TFlags flags)=0 |
Pass flags to the underlying storage. More... | |
virtual void | SetTimeStampPolicy (TTimeStampFlags policy, unsigned int timeout, unsigned int max_timeout=0)=0 |
Set timestamp update policy. More... | |
virtual TTimeStampFlags | GetTimeStampPolicy () const =0 |
Get timestamp policy. More... | |
virtual int | GetTimeout () const =0 |
Get expiration timeout. More... | |
virtual bool | IsOpen () const =0 |
virtual void | SetVersionRetention (EKeepVersions policy)=0 |
Set version retention policy. More... | |
virtual EKeepVersions | GetVersionRetention () const =0 |
Get version retention. More... | |
virtual void | Store (const string &key, TBlobVersion version, const string &subkey, const void *data, size_t size, unsigned int time_to_live=0, const string &owner=kEmptyStr)=0 |
Add or replace BLOB. More... | |
virtual size_t | GetSize (const string &key, TBlobVersion version, const string &subkey)=0 |
Check if BLOB exists, return BLOB size. More... | |
virtual void | GetBlobOwner (const string &key, TBlobVersion version, const string &subkey, string *owner)=0 |
Retrieve BLOB owner. More... | |
virtual bool | Read (const string &key, TBlobVersion version, const string &subkey, void *buf, size_t buf_size)=0 |
Fetch the BLOB. More... | |
virtual IReader * | GetReadStream (const string &key, TBlobVersion version, const string &subkey)=0 |
Return sequential stream interface to read BLOB data. More... | |
virtual IReader * | GetReadStream (const string &key, const string &subkey, TBlobVersion *version, EBlobVersionValidity *validity)=0 |
Request the latest version of a BLOB. More... | |
virtual void | SetBlobVersionAsCurrent (const string &key, const string &subkey, TBlobVersion version)=0 |
Set current valid version for a BLOB. More... | |
virtual void | GetBlobAccess (const string &key, TBlobVersion version, const string &subkey, SBlobAccessDescr *blob_descr)=0 |
Get BLOB access using BlobAccessDescr. More... | |
virtual IWriter * | GetWriteStream (const string &key, TBlobVersion version, const string &subkey, unsigned int time_to_live=0, const string &owner=kEmptyStr)=0 |
Return sequential stream interface to write BLOB data. More... | |
virtual void | Remove (const string &key, TBlobVersion version, const string &subkey)=0 |
Remove specific cache entry. More... | |
virtual time_t | GetAccessTime (const string &key, TBlobVersion version, const string &subkey)=0 |
Return last access time for the specified cache entry. More... | |
virtual bool | HasBlobs (const string &key, const string &subkey)=0 |
Check if any BLOB exists (any version) More... | |
virtual void | Purge (time_t access_timeout)=0 |
Delete all BLOBs older than specified. More... | |
virtual void | Purge (const string &key, const string &subkey, time_t access_timeout)=0 |
Delete BLOBs with access time older than specified. More... | |
virtual | ~ICache () |
virtual bool | SameCacheParams (const TCacheParams *params) const =0 |
virtual string | GetCacheName (void) const =0 |
BLOB cache read/write/maintenance interface.
ICache describes caching service. Any large binary object can be stored in cache and later retrieved. Such cache is a temporary storage and some objects can be purged from cache based on an immediate request, version or access time based replacement (or another implementation specific depreciation rule).
Cache elements are accessed by key-subkey pair, and there can exist more than one version of the "same" (that correspond to the same key-subkey pair) element.
Definition at line 63 of file icache.hpp.
Backward-compatibility typedef.
Definition at line 284 of file icache.hpp.
Definition at line 124 of file icache.hpp.
typedef int ICache::TBlobVersion |
Definition at line 66 of file icache.hpp.
Key values to search for a cache with given params.
Used to share cache between readers and writers.
Definition at line 469 of file icache.hpp.
typedef int ICache::TFlags |
Bitwise OR of "EFlags" flags.
Definition at line 89 of file icache.hpp.
typedef int ICache::TTimeStampFlags |
Holds a bitwise OR of "ETimeStampFlags".
Definition at line 128 of file icache.hpp.
BLOB version existence and validity – from the point of view of the underlying cache implementation.
The underlying cache implementation can expire blobs without actually deleting them. Then, the blob can still be read from the cache, and its validity confirmed (or not) against the original data source, and then its version usually validated (or invalidated) in the cache, accordingly.
Enumerator | |
---|---|
eCurrent | The returned BLOB's version is considered valid. |
eExpired | Validity of the BLOB version cannot be confirmed. |
eValid | Synonym for eCurrent. |
Definition at line 274 of file icache.hpp.
enum ICache::EFlags |
Flags for the underlying storage.
Definition at line 69 of file icache.hpp.
If to keep already cached versions of the BLOB when storing another version of it (not necessarily a newer one)
Definition at line 162 of file icache.hpp.
ICache keeps timestamps of every cache entry.
This enum defines the policy how it is managed. Different policies can be combined by OR (|)
Definition at line 104 of file icache.hpp.
|
inlinevirtual |
Definition at line 465 of file icache.hpp.
|
pure virtual |
Return last access time for the specified cache entry.
Class implementation may want to implement access time based aging scheme for cache managed objects. In this case it needs to track time of every request to BLOB data.
key | BLOB identification key |
subkey | BLOB identification subkey |
version | BLOB version |
Implemented in CAsyncWriteCache, CSQLITE3_Cache, CBDB_Cache, and CNetICacheClient.
|
pure virtual |
Get BLOB access using BlobAccessDescr.
Method fills blob_descr parameter. If provided buffer has sufficient capacity for BLOB storage, BLOB is saved into the buffer, otherwise IReader is created.
Implemented in CAsyncWriteCache, CSQLITE3_Cache, CBDB_Cache, and CNetICacheClient.
Referenced by CCacheHashedContent::GetHashedContent(), CCacheHashedContent::GetMediatorKeyContent(), CCacheHashedContent::StoreHashedContentByMediator(), and CCacheHashedContent::x_CheckHashContent().
|
pure virtual |
Retrieve BLOB owner.
owner | BLOB owner (as used by method Store) |
Implemented in CAsyncWriteCache, CSQLITE3_Cache, CBDB_Cache, and CNetICacheClient.
|
pure virtual |
Implemented in CAsyncWriteCache, CSQLITE3_Cache, CBDB_Cache, and CNetICacheClient.
|
pure virtual |
Retrieve the effective combination of flags from the underlying storage.
Implemented in CAsyncWriteCache, CSQLITE3_Cache, CBDB_Cache, and CNetICacheClient.
|
pure virtual |
Request the latest version of a BLOB.
[in] | key | BLOB identification key |
[in] | subkey | BLOB identification subkey |
[out] | version | Version of the returned BLOB |
[out] | validity | Validity of the version of the returned BLOB |
Implemented in CAsyncWriteCache, CSQLITE3_Cache, CBDB_Cache, and CNetICacheClient.
|
pure virtual |
Return sequential stream interface to read BLOB data.
key | BLOB identification key |
subkey | BLOB identification subkey |
version | BLOB version |
Implemented in CAsyncWriteCache, CSQLITE3_Cache, CBDB_Cache, and CNetICacheClient.
Referenced by CCacheHashedContent::GetHashedContent(), CCgiApplication::GetSavedRequest(), s_ReadData(), CSGSegmentSmearJob::x_LoadFromNetCache(), CSparseGraph::x_ReadData(), CSparseGraph::x_ReadMap(), and CWigGraph::x_ReadSummary().
|
pure virtual |
Check if BLOB exists, return BLOB size.
key | BLOB identification key |
subkey | BLOB identification subkey |
version | BLOB version |
Implemented in CAsyncWriteCache, CSQLITE3_Cache, CBDB_Cache, and CNetICacheClient.
Referenced by CSplitCacheApp::ProcessBlob(), CSplitCacheApp::ProcessEntry(), s_ReadData(), CSparseGraph::x_ReadData(), CSparseGraph::x_ReadMap(), and CWigGraph::x_ReadSummary().
|
pure virtual |
Get expiration timeout.
Implemented in CAsyncWriteCache, CSQLITE3_Cache, CBDB_Cache, and CNetICacheClient.
Referenced by CCacheCleanerThread::DoJob().
|
pure virtual |
Get timestamp policy.
Implemented in CAsyncWriteCache, CSQLITE3_Cache, CBDB_Cache, and CNetICacheClient.
|
pure virtual |
Get version retention.
Implemented in CAsyncWriteCache, CSQLITE3_Cache, CBDB_Cache, and CNetICacheClient.
|
pure virtual |
Return sequential stream interface to write BLOB data.
key | BLOB identification key |
subkey | BLOB identification subkey |
version | BLOB version |
time_to_live | Individual timeout |
Implemented in CAsyncWriteCache, CSQLITE3_Cache, CBDB_Cache, and CNetICacheClient.
Referenced by CCgiApplication::SaveRequest(), CCacheHashedContent::StoreHashedContent(), CCacheHashedContent::StoreHashedContentByMediator(), CCacheWriter::WriteSeq_ids(), CBedCoverageGraph::x_SaveData(), CVcfHeatmap::x_SaveData(), CWigGraph::x_SaveSummary(), CSparseGraph::x_WriteData(), and CSGSegmentSmearJob::x_WriteToCache().
Check if any BLOB exists (any version)
Implemented in CAsyncWriteCache, CSQLITE3_Cache, CBDB_Cache, and CNetICacheClient.
Referenced by CCacheReader::LoadChunk(), and CSGSegmentSmearJob::x_Execute().
|
pure virtual |
Implemented in CAsyncWriteCache, CSQLITE3_Cache, CBDB_Cache, and CNetICacheClient.
|
pure virtual |
Delete BLOBs with access time older than specified.
Function finds all BLOB versions with the specified key and removes the old instances.
key | BLOB key |
subkey | BLOB identification subkey |
access_timeout | Time in seconds. All objects older than this are deleted. |
Implemented in CAsyncWriteCache, CSQLITE3_Cache, CBDB_Cache, and CNetICacheClient.
|
pure virtual |
Delete all BLOBs older than specified.
access_timeout | Time in seconds. All objects older than this are deleted. |
Implemented in CAsyncWriteCache, CSQLITE3_Cache, CBDB_Cache, and CNetICacheClient.
Referenced by CCacheCleanerThread::DoJob().
|
pure virtual |
Fetch the BLOB.
key | BLOB identification key |
subkey | BLOB identification subkey |
version | BLOB version |
buf | pointer on destination buffer |
size | buffer size in bytes (chars) |
Implemented in CAsyncWriteCache, CSQLITE3_Cache, CBDB_Cache, and CNetICacheClient.
|
pure virtual |
Remove specific cache entry.
key | BLOB identification key |
subkey | BLOB identification subkey |
version | BLOB version |
Implemented in CAsyncWriteCache, CSQLITE3_Cache, CBDB_Cache, and CNetICacheClient.
Referenced by CSplitCacheApp::ProcessBlob(), CSplitCacheApp::ProcessEntry(), CCacheHashedContent::StoreHashedContentByMediator(), and CCacheWriter::WriteSeq_ids().
|
pure virtual |
Implemented in CAsyncWriteCache, CSQLITE3_Cache, CBDB_Cache, and CNetICacheClient.
|
pure virtual |
Set current valid version for a BLOB.
[in] | key | BLOB identification key |
[in] | subkey | BLOB identification subkey |
[in] | version | BLOB version which must be considered valid from now on |
Implemented in CAsyncWriteCache, CBDB_Cache, and CNetICacheClient.
Referenced by CCacheReader::x_SetBlobVersionAsCurrent().
|
pure virtual |
Pass flags to the underlying storage.
Implemented in CAsyncWriteCache, CSQLITE3_Cache, CBDB_Cache, and CNetICacheClient.
|
pure virtual |
Set timestamp update policy.
policy | A bitwise combination of "ETimeStampFlags". |
timeout | Default expiration timeout for the stored BLOBs. |
max_timeout | Maximum value for individually set BLOB timeouts. If "max_timeout" < "timeout", then it 'll be set to "timeout". |
Implemented in CSQLITE3_Cache, CBDB_Cache, CNetICacheClient, and CAsyncWriteCache.
Referenced by CICacheCF< CNetICacheClient >::ConfigureTimeStamp().
|
pure virtual |
Set version retention policy.
policy | Version retention mode |
Implemented in CAsyncWriteCache, CSQLITE3_Cache, CBDB_Cache, and CNetICacheClient.
Referenced by CICacheCF< CNetICacheClient >::ConfigureICache().
|
pure virtual |
Add or replace BLOB.
key | BLOB identification key |
key | BLOB identification sub-key |
version | BLOB version |
data | pointer on data buffer |
size | data buffer size in bytes (chars) |
time_to_live | Individual timeout. Cannot exceed max timeout. |
Implemented in CAsyncWriteCache, CSQLITE3_Cache, CBDB_Cache, and CNetICacheClient.
Referenced by CCacheHashedContent::StoreHashedContent(), CCacheHashedContent::StoreHashedContentByMediator(), CCacheHashedContent::StoreMediatorKeyContent(), and CCacheWriter::x_WriteId().