1 #ifndef UTIL_ICACHE_CF__HPP
2 #define UTIL_ICACHE_CF__HPP
51 template<
class TDriver>
59 CICacheCF(
const string& driver_name,
int patch_level = -1)
60 :
TParent(driver_name, patch_level)
71 static const char* kCFParam_timestamp =
"timestamp";
73 const string& ts_flags_str =
74 this->
GetParam(params, kCFParam_timestamp,
false);
76 if (!ts_flags_str.empty()) {
83 static const char* kCFParam_keep_versions =
"keep_versions";
85 const string& keep_versions_str =
86 this->
GetParam(params, kCFParam_keep_versions,
false);
87 if (!keep_versions_str.empty()) {
88 static const char* kCFParam_keep_versions_all =
"all";
89 static const char* kCFParam_keep_versions_drop_old =
"drop_old";
90 static const char* kCFParam_keep_versions_drop_all =
"drop_all";
94 kCFParam_keep_versions_all)==0) {
98 kCFParam_keep_versions_drop_old)==0) {
102 kCFParam_keep_versions_drop_all)==0) {
106 <<
"ICache::ClassFactory: Unknown keep_versions"
107 " policy parameter: "
108 << keep_versions_str);
118 const string& options)
const
121 const char* kCFParam_timeout =
"timeout";
123 const char* kCFParam_max_timeout =
"max_timeout";
126 const char* kCFParam_timestamp_onread =
"onread";
128 const char* kCFParam_timestamp_subkey =
"subkey";
130 const char* kCFParam_timestamp_expire_not_used =
"expire_not_used";
132 const char* kCFParam_timestamp_purge_on_startup =
"purge_on_startup";
134 const char* kCFParam_timestamp_check_expiration =
"check_expiration";
139 ITERATE(list<string>, it, opt) {
140 const string& opt_value = *it;
142 kCFParam_timestamp_onread)==0) {
147 kCFParam_timestamp_subkey)==0) {
152 kCFParam_timestamp_expire_not_used)==0) {
157 kCFParam_timestamp_purge_on_startup)==0) {
162 kCFParam_timestamp_check_expiration)==0) {
167 <<
"ICache::ClassFactory: Unknown timeout policy parameter: "
172 unsigned int timeout = (
unsigned int)
173 this->
GetParamInt(params, kCFParam_timeout,
false, 60 * 60);
174 unsigned int max_timeout = (
unsigned int)
175 this->
GetParamInt(params, kCFParam_max_timeout,
false, 0);
177 if (max_timeout && max_timeout < timeout)
178 max_timeout = timeout;
Class for deferred asynchronous writes in a separate thread.
Utility class for ICache class factories.
TParent::TInterface * CreateInstance(const string &driver=kEmptyStr, CVersionInfo version=TParent::GetDefaultDrvVers(), const TPluginManagerParamTree *params=0) const final
Create instance of TDriver.
virtual TParent::TInterface * x_CreateInstance(const string &driver=kEmptyStr, CVersionInfo version=TParent::GetDefaultDrvVers(), const TPluginManagerParamTree *params=0) const =0
void ConfigureTimeStamp(ICache *icache, const TPluginManagerParamTree *params, const string &options) const
CSimpleClassFactoryImpl< ICache, TDriver > TParent
void ConfigureICache(ICache *icache, const TPluginManagerParamTree *params) const
Utility function, configures common ICache parameters.
CICacheCF(const string &driver_name, int patch_level=-1)
Template class helps to implement one driver class factory.
definition of a Culling tree
BLOB cache read/write/maintenance interface.
EKeepVersions
If to keep already cached versions of the BLOB when storing another version of it (not necessarily a ...
@ eDropOlder
Delete the earlier (than the one being stored) versions of the BLOB.
@ eDropAll
Delete all versions of the BLOB, even those which are newer than the one being stored.
@ eKeepAll
Do not delete other versions of cache entries.
virtual void SetVersionRetention(EKeepVersions policy)=0
Set version retention policy.
virtual void SetTimeStampPolicy(TTimeStampFlags policy, unsigned int timeout, unsigned int max_timeout=0)=0
Set timestamp update policy.
@ fTimeStampOnRead
Timestamp is updated every on every access (read or write)
@ fExpireLeastFrequentlyUsed
Expire objects older than a certain time frame Example: If object is not accessed within a week it is...
@ fTrackSubKey
Timestamp full key-subkey pair.
@ fPurgeOnStartup
Expired objects should be deleted on cache mount (Open)
@ fCheckExpirationAlways
Expiration timeout is checked on any access to cache element.
int TTimeStampFlags
Holds a bitwise OR of "ETimeStampFlags".
Include a standard set of the NCBI C++ Toolkit most basic headers.
The NCBI C++ standard methods for dealing with std::string.
int main(int argc, const char *argv[])
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define ERR_POST_XX(error_name, err_subcode, message)
Error posting with error code having given name and with given error subcode.
void Warning(CExceptionArgs_Base &args)
double GetParamDouble(const TPluginManagerParamTree *params, const string ¶m_name, bool, double default_value) const
Utility function to get a double of parameter tree Throws an exception when mandatory parameter is mi...
static const CVersionInfo & GetDefaultDrvVers(void)
int GetParamInt(const TPluginManagerParamTree *params, const string ¶m_name, bool, int default_value) const
Utility function to get an integer of parameter tree Throws an exception when mandatory parameter is ...
bool GetParamBool(const TPluginManagerParamTree *params, const string ¶m_name, bool, bool default_value) const
Utility function to get an bool of parameter tree Throws an exception when mandatory parameter is mis...
string GetParam(const TPluginManagerParamTree *params, const string ¶m_name, bool mandatory, const string &default_value) const
Utility function to get an element of parameter tree Throws an exception when mandatory parameter is ...
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static int CompareNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive compare of a substring with another string.
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
@ fSplit_Tokenize
All delimiters are merged and trimmed, to get non-empty tokens only.
unsigned int
A callback function used to compare two keys in a database.
Interfaces for a local cache of versioned binary large objects (BLOBS).
Definition of all error codes used in util (xutil.lib).
Plugin manager (using class factory paradigm).
Helper classes and templates to implement plugins.