StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StHyperCacheWebservice.h
1 // StHyperCacheWebservice.h
2 #ifndef __ST_HYPERCACHEWEBSERVICE_H
3 #define __ST_HYPERCACHEWEBSERVICE_H
4 
5 #include "StHyperCacheI.h"
6 #include "StHyperCacheFactory.h"
7 
8 #include <curl/curl.h>
9 #include <curl/easy.h>
10 
12 {
13 public:
16 
17  // initialization procedures like memcache server connect or file cache initialization
18  bool init();
19 
20  // get cached object(s) by primary key. returns pointer to data, which length is passed by reference
21  const char* get(const std::string& group_key, const std::string& key, size_t& value_length);
22  // put object to cache
23  bool set(const std::string& group_key, const std::string& key, const char* data, size_t dataLength, time_t expirationTime = 0);
24  // replace existing object in cache with one provided
25  bool replace(const std::string& group_key, const std::string& key, const char* data, size_t dataLength, time_t expirationTime = 0);
26  // remove existing object from cache, if exists
27  bool remove(const std::string& group_key, const std::string& key);
28  // remove all entries from cache
29  void clear();
30 
31  // return some statistics parameters for this cache
32  std::string getStat();
33  // return cache name (underlying engine)
34  const std::string& getName() { return m_Name; };
35  // return cache implementation version
36  const std::string& getVersion() { return m_Version; };
37  // return cache type
38  const std::string& getType() { return m_Type; };
39 
40  static StHyperCacheI* ptr;
41 
42 protected:
43 
44  static bool m_IsInitialized;
45 
46  std::string m_Name;
47  std::string m_Version;
48  std::string m_Type;
49 
50  CURL* curl;
51 
52  std::string m_URI;
53  char m_JsonErrorBuffer[CURL_ERROR_SIZE];
54  std::string m_JsonBuffer;
55 
56 };
57 
58 StHyperCacheI* getStHyperCacheWebservice();
59 
60 #endif // __ST_HYPERCACHEWEBSERVICE_H
61