1 #ifndef GUI_WIDGETS_SEQ_GRAPHIC___GRAPH_CACHE__HPP
2 #define GUI_WIDGETS_SEQ_GRAPHIC___GRAPH_CACHE__HPP
45 #include <condition_variable>
100 return s_Cache.
Get();
106 }
catch (exception& e) {
128 lock_guard<mutex> lock(
m_Lock);
129 if (
m_Cache.count(data_key) != 0)
144 lock_guard<mutex> lock(
m_Lock);
145 if (
m_Cache.count(data_key) > 0)
148 data =
Ref(
new TData(data_key));
163 lock_guard<mutex> lock(
m_Lock);
186 lock_guard<mutex> lock(
m_Lock);
210 unique_lock<mutex> lock(
m_Lock);
217 lock_guard<mutex> lock(
m_Lock);
< Storage factory provides ICache instance for permanent storage of cached data
CGraphCacheFactory(const string ¶m)
void DeleteObject(ICache *obj)
ICache * CreateObject(void)
void SaveData(CRef< TData > data)
Clones TData, puts it into Save Queue for asynchroneous storage operation.
void RemoveData(const string &data_key)
Removes Data from in-memory cache.
mutex m_Lock
Saving Queue and Cache lock.
queue< CRef< TData > > m_Queue
Saving Queue for storage operations.
TGraphCachePool m_Storage
ICache pool.
void EnableICache(bool value)
thread m_Thread
background thread for save processing
map< TDataKey, CRef< TData > > m_Cache
in-memory data cache
CRef< TData > GetData(const string &data_key)
Retrieves TData from in-memory cache or if not found calls TData::Init to initialize new TData instan...
void x_Run(CRef< CRequestContext > context)
CGraphCache(const CGraphCache &)=delete
condition_variable m_CV
wake-up signal for save requests
static CGraphCache & GetInstance()
atomic< bool > m_StopRequested
flag to stop the backround thread
CRef< TData > GetCachedData(const string &data_key)
Retrieves TData from in-memory cache.
bool m_HasICache
Flag indicates if data should be saved into ICache.
CGraphCache & operator=(const CGraphCache &)=delete
static CNcbiApplication * Instance(void)
Singleton method.
Client to NetCache server (implements ICache interface)
Helper class for object allocation/deallocation.
T & Get(void)
Create the variable if not created yet, return the reference.
BLOB cache read/write/maintenance interface.
const_iterator end() const
const_iterator find(const key_type &key) const
const CNcbiRegistry & GetConfig(void) const
Get the application's cached configuration parameters (read-only).
static void SetRequestContext(CRequestContext *ctx)
Shortcut to CDiagContextThreadData::GetThreadData().SetRequestContext()
static CRequestContext & GetRequestContext(void)
Shortcut to CDiagContextThreadData::GetThreadData().GetRequestContext()
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
void Error(CExceptionArgs_Base &args)
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
virtual string GetString(const string §ion, const string &name, const string &default_value, TFlags flags=0) const
Get the parameter string value.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Interfaces for a local cache of versioned binary large objects (BLOBS).
const GenericPointer< typename T::ValueType > T2 value
Defines NCBI C++ diagnostic APIs, classes, and macros.
NetCache ICache client specs.
Defines CRequestContext class for NCBI C++ diagnostic API.
static CNamedPipeClient * client
static CS_CONTEXT * context