identt
StoreCache.hpp
Go to the documentation of this file.
1 
33 #ifndef _IDENTT_STORE_STORECACHE_HPP_
34 #define _IDENTT_STORE_STORECACHE_HPP_
35 
36 #include <memory>
37 #include <unordered_map>
38 #include <utility>
39 #include <functional>
40 #include <boost/thread/locks.hpp>
41 #include <boost/thread/shared_mutex.hpp>
42 
43 #include <store/StoreBase.hpp>
44 
45 namespace identt {
46 namespace store {
47 class StoreCache : virtual public StoreBase {
48 public:
49 
50  using pointer=std::shared_ptr<StoreCache>;
51  using LockT = boost::shared_mutex;
52  using WriteLockT = boost::unique_lock< LockT >;
53  using ReadLockT = boost::shared_lock< LockT >;
54 
55 
56  using AssocT = std::string;
57  using AssocMapT = std::unordered_map<std::string,AssocT>;
58 
65  static pointer create()
66  {
67  pointer p(new StoreCache());
68  return p;
69  }
70 
71 
73  StoreCache(const StoreCache&) = delete;
74  StoreCache& operator=(const StoreCache&) = delete;
75 
79  virtual ~StoreCache ();
80 
93  void SetAssoc(std::string hash, AssocT assoc);
94 
95 
108  bool GetAssoc(std::string hash, AssocT& assoc);
109 
119  void DelAssoc(std::string hash);
120 
130  void AddToCache(TransactionT* trans);
131 
132 private:
133  LockT mutex_;
134  AssocMapT assoc_map;
135 
140  StoreCache();
141 
142 };
143 } // namespace store
144 } // namespace identt
145 #endif /* _IDENTT_STORE_STORECACHE_HPP_ */
static pointer create()
create : static construction creates new first time
Definition: StoreCache.hpp:65
void AddToCache(TransactionT *trans)
AddToCache : adds a transaction to cache.
Definition: StoreCache.cc:90
Definition: StoreCache.hpp:47
void DelAssoc(std::string hash)
DelAssoc : del assoc entry.
Definition: StoreCache.cc:77
Definition: StoreBase.hpp:58
void SetAssoc(std::string hash, AssocT assoc)
SetAssoc : add an assoc entry.
Definition: StoreCache.cc:51
Definition: CryptoBase.hpp:49
bool GetAssoc(std::string hash, AssocT &assoc)
GetAssoc : get assoc.
Definition: StoreCache.cc:62
virtual ~StoreCache()
destructor
Definition: StoreCache.cc:45