StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StHyperCacheFileLocal.h
1 // StHyperCacheFileLocal.h
2 #ifndef __ST_HYPERCACHEFILELOCAL_H
3 #define __ST_HYPERCACHEFILELOCAL_H
4 
5 #include "StHyperCacheI.h"
6 #include "StHyperCacheFactory.h"
7 
9 {
10 public:
13 
14  // initialization procedures like memcache server connect or file cache initialization
15  bool init();
16 
17  // get cached object(s) by primary key. returns pointer to data, which length is passed by reference
18  const char* get(const std::string& group_key, const std::string& key, size_t& value_length);
19  // put object to cache
20  bool set(const std::string& group_key, const std::string& key, const char* data, size_t dataLength, time_t expirationTime = 0);
21  // replace existing object in cache with one provided
22  bool replace(const std::string& group_key, const std::string& key, const char* data, size_t dataLength, time_t expirationTime = 0);
23  // remove existing object from cache, if exists
24  bool remove(const std::string& group_key, const std::string& key);
25  // remove all entries from cache
26  void clear();
27 
28  // return some statistics parameters for this cache
29  std::string getStat();
30  // return cache name (underlying engine)
31  const std::string& getName() { return m_Name; };
32  // return cache implementation version
33  const std::string& getVersion() { return m_Version; };
34  // return cache type
35  const std::string& getType() { return m_Type; };
36 
37  static StHyperCacheI* ptr;
38 
39 protected:
40 
41  static bool m_IsInitialized;
42 
43  std::string m_Name;
44  std::string m_Version;
45  std::string m_Type;
46 
47  std::string m_BasePath;
48  std::string m_AltBasePath;
49  std::string m_Path;
50 
51  std::string m_Policy;
52 
53  int m_MaxCacheSizeMb;
54  int m_MaxItemSizeKb;
55  float m_DiskFreeUpper;
56  float m_DiskFreeLower;
57  std::string m_IgnoreKeywords;
58 
59  std::string m_StartEmpty;
60 
61  void doCacheCleanup();
62  void getDiskUsage(size_t& bytes_free, size_t& bytes_total);
63 
64 };
65 
66 StHyperCacheI* getStHyperCacheFileLocal();
67 
68 #endif // __ST_HYPERCACHEFILELOCAL_H
69