Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/classCAsyncWriteCache.html below:
NCBI C++ ToolKit: CAsyncWriteCache Class Reference
Search Toolkit Book for CAsyncWriteCache
Class for deferred asynchronous writes in a separate thread. More...
#include <util/cache/cache_async.hpp>
CAsyncWriteCache (ICache *main, ICache *writer, double grace_period=0.0) Constructor. More...
TFlags GetFlags () override ICache overrides. More...
void SetFlags (TFlags flags) override Pass flags to the underlying storage. More...
void SetTimeStampPolicy (TTimeStampFlags policy, unsigned int timeout, unsigned int max_timeout) override Set timestamp update policy. More...
TTimeStampFlags GetTimeStampPolicy () const override Get timestamp policy. More...
int GetTimeout () const override Get expiration timeout. More...
bool IsOpen () const override void SetVersionRetention (EKeepVersions policy) override Set version retention policy. More...
EKeepVersions GetVersionRetention () const override Get version retention. More...
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) override Add or replace BLOB. More...
size_t GetSize (const string &key, TBlobVersion version, const string &subkey) override Check if BLOB exists, return BLOB size. More...
void GetBlobOwner (const string &key, TBlobVersion version, const string &subkey, string *owner) override Retrieve BLOB owner. More...
bool Read (const string &key, TBlobVersion version, const string &subkey, void *buf, size_t buf_size) override Fetch the BLOB. More...
IReader * GetReadStream (const string &key, TBlobVersion version, const string &subkey) override Return sequential stream interface to read BLOB data. More...
IReader * GetReadStream (const string &key, const string &subkey, TBlobVersion *version, EBlobVersionValidity *validity) override Request the latest version of a BLOB. More...
void SetBlobVersionAsCurrent (const string &key, const string &subkey, TBlobVersion version) override Set current valid version for a BLOB. More...
void GetBlobAccess (const string &key, TBlobVersion version, const string &subkey, SBlobAccessDescr *blob_descr) override Get BLOB access using BlobAccessDescr. More...
IWriter * GetWriteStream (const string &key, TBlobVersion version, const string &subkey, unsigned int time_to_live=0, const string &owner=kEmptyStr) override Return sequential stream interface to write BLOB data. More...
void Remove (const string &key, TBlobVersion version, const string &subkey) override Remove specific cache entry. More...
time_t GetAccessTime (const string &key, TBlobVersion version, const string &subkey) override Return last access time for the specified cache entry. More...
bool HasBlobs (const string &key, const string &subkey) override Check if any BLOB exists (any version) More...
void Purge (time_t access_timeout) override Delete all BLOBs older than specified. More...
void Purge (const string &key, const string &subkey, time_t access_timeout) override Delete BLOBs with access time older than specified. More...
~CAsyncWriteCache () override bool SameCacheParams (const TCacheParams *params) const override string GetCacheName (void) const override virtual ~ICache () 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...
Class for deferred asynchronous writes in a separate thread.
-
Warning
-
This class writes synchronously (immediately) in single thread builds
Definition at line 48 of file cache_async.hpp.
◆ CAsyncWriteCache() CAsyncWriteCache::CAsyncWriteCache ( ICache * main, ICache * writer, double grace_period = 0.0
)
Constructor.
-
Parameters
-
main Main ICache instance used for all but write/store operations writer ICache instance used solely for write/store operations (in a separate thread, unless disabled) grace_period Seconds to wait for the write thread before cancelling all its queued tasks. Zero means cancelling all queued tasks immediately, already executing task (if any) will try to finish.
Definition at line 149 of file cache_async.cpp.
References _ASSERT, and main().
◆ ~CAsyncWriteCache() CAsyncWriteCache::~CAsyncWriteCache ( ) override ◆ GetAccessTime() ◆ GetBlobAccess() ◆ GetBlobOwner() ◆ GetCacheName() string CAsyncWriteCache::GetCacheName ( void ) const overridevirtual ◆ GetFlags() ◆ GetReadStream() [1/2]
Request the latest version of a BLOB.
-
Parameters
-
[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
-
Returns
-
Sequential stream interface to read BLOB data. Return NULL if the BLOB data is not found in the cache.
-
Note
-
If the BLOB data is not found in the cache, then neither 'version' nor 'validity' values will be set by the method.
-
See also
-
SetCurrentBlobVersion()
Implements ICache.
Definition at line 260 of file cache_async.cpp.
References ncbi::grid::netcache::search::fields::key, m_Main, ncbi::grid::netcache::search::fields::subkey, and dtl::version.
◆ GetReadStream() [2/2] ◆ GetSize() ◆ GetTimeout() int CAsyncWriteCache::GetTimeout ( ) const overridevirtual ◆ GetTimeStampPolicy() ◆ GetVersionRetention() ◆ GetWriteStream() ◆ HasBlobs() ◆ IsOpen() bool CAsyncWriteCache::IsOpen ( ) const overridevirtual ◆ Purge() [1/2] ◆ Purge() [2/2] void CAsyncWriteCache::Purge ( time_t access_timeout ) overridevirtual
Delete all BLOBs older than specified.
-
Parameters
-
access_timeout Time in seconds. All objects older than this are deleted.
Implements ICache.
Definition at line 308 of file cache_async.cpp.
References m_Main.
◆ Read() ◆ Remove() ◆ SameCacheParams() ◆ SetBlobVersionAsCurrent()
Set current valid version for a BLOB.
-
Parameters
-
[in] key BLOB identification key [in] subkey BLOB identification subkey [in] version BLOB version which must be considered valid from now on
-
Note
-
Throw exception in case of transient errors.
-
There is an important special case: if the underlying storage is inherently incapable of storing BLOB version info without storing the BLOB itself, and there is currently no blob with the specified key/subkey/version present in the cache, then this function will just do nothing, and it will not throw exception.
-
See also
-
GetReadStream()
Implements ICache.
Definition at line 266 of file cache_async.cpp.
References ncbi::grid::netcache::search::fields::key, m_Main, ncbi::grid::netcache::search::fields::subkey, and dtl::version.
◆ SetFlags() void CAsyncWriteCache::SetFlags ( TFlags flags ) overridevirtual ◆ SetTimeStampPolicy() void CAsyncWriteCache::SetTimeStampPolicy ( TTimeStampFlags policy, unsigned int timeout, unsigned int max_timeout ) overridevirtual
Set timestamp update policy.
-
Parameters
-
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".
Implements ICache.
Definition at line 186 of file cache_async.cpp.
References m_Main.
◆ SetVersionRetention() void CAsyncWriteCache::SetVersionRetention ( EKeepVersions policy ) overridevirtual
Set version retention policy.
-
Parameters
-
policy Version retention mode
Implements ICache.
Definition at line 210 of file cache_async.cpp.
References m_Main.
◆ Store() ◆ m_GracePeriod CTimeout CAsyncWriteCache::m_GracePeriod private ◆ m_Main unique_ptr<ICache> CAsyncWriteCache::m_Main private
Definition at line 96 of file cache_async.hpp.
Referenced by GetAccessTime(), GetBlobAccess(), GetBlobOwner(), GetCacheName(), GetFlags(), GetReadStream(), GetSize(), GetTimeout(), GetTimeStampPolicy(), GetVersionRetention(), HasBlobs(), IsOpen(), Purge(), Read(), Remove(), SameCacheParams(), SetBlobVersionAsCurrent(), SetFlags(), SetTimeStampPolicy(), and SetVersionRetention().
◆ m_ThreadPool ◆ m_Writer shared_ptr<ICache> CAsyncWriteCache::m_Writer private
The documentation for this class was generated from the following files:
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4