Granada  1.54.0
Structured layer on top of C++ REST SDK for building server applications in C++. Granada implements sessions, server side plug-in framework, C++ OAuth 2.0 server, data storage access, server script running, server browsing.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
cache_handler.h
Go to the documentation of this file.
1 
28 #pragma once
29 #include <memory>
30 #include <mutex>
31 #include <string>
32 #include <vector>
33 #include "granada/util/memory.h"
34 
35 namespace granada{
36  namespace cache{
37 
42 
43  public:
44 
45 
50 
51 
66  CacheHandlerIterator(const std::string& expression){
67  set(expression);
68  };
69 
70 
74  virtual ~CacheHandlerIterator(){};
75 
76 
83  virtual void set(const std::string& expression){
84  expression_.assign(expression);
85  };
86 
87 
93  virtual const bool has_next() = 0;
94 
95 
100  virtual const std::string next() = 0;
101 
102 
103  protected:
104 
119  std::string expression_;
120 
121  };
122 
123 
129  {
130 
131  public:
132 
133 
138 
139 
143  virtual ~CacheHandler(){};
144 
145 
151  virtual const bool Exists(const std::string& key) = 0;
152 
153 
160  virtual const bool Exists(const std::string& hash,const std::string& key) = 0;
161 
162 
168  virtual const std::string Read(const std::string& key) = 0;
169 
170 
177  virtual const std::string Read(const std::string& hash, const std::string& key) = 0;
178 
179 
194  virtual const void Match(const std::string& expression, std::vector<std::string>& keys){
195  keys.clear();
196  std::unique_ptr<granada::cache::CacheHandlerIterator> cache_iterator = this->make_iterator(expression);
197  while (cache_iterator->has_next()){
198  keys.push_back(cache_iterator->next());
199  }
200  };
201 
202 
208  virtual void Write(const std::string& key,const std::string& value) = 0;
209 
210 
218  virtual void Write(const std::string& hash,const std::string& key,const std::string& value) = 0;
219 
220 
225  virtual void Destroy(const std::string& key) = 0;
226 
227 
233  virtual void Destroy(const std::string& hash,const std::string& key) = 0;
234 
235 
246  virtual bool Rename(const std::string& old_key, const std::string& new_key) = 0;
247 
248 
252  virtual std::unique_ptr<granada::cache::CacheHandlerIterator> make_iterator(const std::string& expression) = 0;
253 
254  };
255  }
256 }
virtual void Destroy(const std::string &key)=0
CacheHandlerIterator()
Definition: cache_handler.h:49
std::string expression_
Definition: cache_handler.h:119
virtual const std::string Read(const std::string &key)=0
virtual ~CacheHandlerIterator()
Definition: cache_handler.h:74
CacheHandler()
Definition: cache_handler.h:137
virtual bool Rename(const std::string &old_key, const std::string &new_key)=0
virtual std::unique_ptr< granada::cache::CacheHandlerIterator > make_iterator(const std::string &expression)=0
virtual const std::string next()=0
Definition: cache_handler.h:41
virtual const void Match(const std::string &expression, std::vector< std::string > &keys)
Definition: cache_handler.h:194
virtual void set(const std::string &expression)
Definition: cache_handler.h:83
virtual const bool Exists(const std::string &key)=0
virtual void Write(const std::string &key, const std::string &value)=0
virtual const bool has_next()=0
Definition: cache_handler.h:128
virtual ~CacheHandler()
Definition: cache_handler.h:143
CacheHandlerIterator(const std::string &expression)
Definition: cache_handler.h:66