Infinispan HotRod C++ Client  8.2.1.Final
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
RemoteCache.h
Go to the documentation of this file.
1 #ifndef ISPN_HOTROD_REMOTECACHE_H
2 #define ISPN_HOTROD_REMOTECACHE_H
3 
19 #include <cmath>
20 #include <set>
21 #include <map>
22 #include <sstream>
23 #include <stdexcept>
24 #include <vector>
25 #include <functional>
26 #include <future>
27 #include <iterator>
28 
29 namespace infinispan
30 {
31 namespace hotrod
32 {
33 
64 template<class K, class V> class RemoteCache: private RemoteCacheBase
65 {
66 private:
67 #ifndef SWIG // Let SWIG ignore this method
68  template<typename Function>
69  inline std::future<typename std::result_of<Function()>::type> goAsync(Function&& f,
70  std::function<typename std::result_of<Function()>::type(typename std::result_of<Function()>::type)> success,
71  std::function<typename std::result_of<Function()>::type(std::exception&)> fail)
72  {
73  auto fq = [=]
74  { try
75  { return success==0 ? f() : success(f());}
76  catch (std::exception& ex)
77  { if (fail!=0)
78  { return fail(ex);}
79  else
80  { throw ex;}}
81  };
82  return std::async(fq);
83  }
84 
85  template<typename Function>
86  inline std::future<void> goAsync(Function&& f, std::function<void()> success,
87  std::function<void(std::exception&)> fail)
88  {
89  auto fq = [=]
90  { try
91  { if (success==0) f();
92  else success();}
93  catch (std::exception& ex)
94  { if (fail!=0)
95  { fail(ex);}
96  else
97  { throw ex;}}
98  };
99  return std::async(fq);
100  }
101 
102 #endif
103 
104 public:
105 
111  std::string getName()
112  {
113  return std::string(base_getName());
114  }
115 
121  std::string getVersion()
122  {
124  }
125 
131  std::string getProtocolVersion()
132  {
134  }
135 
143  V* get(const K& key)
144  {
145  return (V *) base_get(&key);
146  }
147 
155  std::map<std::shared_ptr<K>, std::shared_ptr<V> > getAll(const std::set<K>& keySet)
156  {
157  std::set<std::vector<char> > keySetMarshalled;
158  for (auto item = keySet.begin(); item != keySet.end(); item++)
159  {
160  std::vector<char> v;
161  this->keyMarshaller->marshall(*item, v);
162  keySetMarshalled.insert(v);
163  }
164  auto marshalledResult = base_getAll(keySetMarshalled);
165  std::map<std::shared_ptr<K>, std::shared_ptr<V> > result;
166  for (auto item : marshalledResult)
167  {
168  std::shared_ptr<K> rk(this->keyMarshaller->unmarshall(item.first));
169  std::shared_ptr<V> rv(this->keyMarshaller->unmarshall(item.second));
170  result[rk] = rv;
171  }
172  return result;
173  }
174 
185  std::future<V*> getAsync(const K& key, std::function<V* (V*)> success = nullptr,
186  std::function<V* (std::exception&)> fail = nullptr)
187  {
188  auto pKey = &key;
189  auto f = [=]
190  { return this->get(*pKey);};
191  return goAsync(f, success, fail);
192  }
193 
213  V* put(const K& key, const V& val, uint64_t lifespan = 0, uint64_t maxIdle = 0)
214  {
215  return put(key, val, lifespan, SECONDS, maxIdle, SECONDS);
216  }
236  V* put(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit)
237  {
238  return put(key, val, lifespan, lifespanUnit, 0, SECONDS);
239  }
240 
262  V* put(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit)
263  {
264  return (V *) base_put(&key, &val, toSeconds(lifespan, lifespanUnit), toSeconds(maxIdle, maxIdleUnit));
265  }
266 
278  std::future<V*> putAsync(const K& key, const V& val, uint64_t lifespan = 0, uint64_t maxIdle = 0,
279  std::function<V* (V*)> success = nullptr, std::function<V* (std::exception&)> fail = nullptr)
280  {
281  auto pKey = &key, pVal = &val;
282  auto f = [=]
283  { return this->put(*pKey,*pVal,lifespan,maxIdle);};
284  return goAsync(f, success, fail);
285  }
286 
298  std::future<V*> putAsync(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit,
299  std::function<V* (V*)> success = nullptr, std::function<V* (std::exception&)> fail = nullptr)
300  {
301  auto pKey = &key, pVal = &val;
302  auto f = [=]
303  { return this->put(*pKey,*pVal,lifespan,lifespanUnit);};
304  return goAsync(f, success, fail);
305  }
306 
320  std::future<V*> putAsync(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle,
321  TimeUnit maxIdleUnit, std::function<V* (V*)> success = nullptr, std::function<V* (std::exception&)> fail =
322  nullptr)
323  {
324  auto pKey = &key, pVal = &val;
325  auto f = [=]
326  { return this->put(*pKey,*pVal,lifespan, lifespanUnit,maxIdle,maxIdleUnit);};
327  return goAsync(f, success, fail);
328  }
329 
340  V* putIfAbsent(const K& key, const V& val, uint64_t lifespan = 0, uint64_t maxIdle = 0)
341  {
342  return putIfAbsent(key, val, lifespan, SECONDS, maxIdle, SECONDS);
343  }
354  V* putIfAbsent(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit)
355  {
356  return putIfAbsent(key, val, lifespan, lifespanUnit, 0, SECONDS);
357  }
370  V* putIfAbsent(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle,
371  TimeUnit maxIdleUnit)
372  {
373  return (V *) base_putIfAbsent(&key, &val, toSeconds(lifespan, lifespanUnit), toSeconds(maxIdle, maxIdleUnit));
374  }
386  std::future<V*> putIfAbsentAsync(const K& key, const V& val, uint64_t lifespan = 0, uint64_t maxIdle = 0,
387  std::function<V* (V*)> success = nullptr, std::function<V* (std::exception&)> fail = nullptr)
388  {
389  auto pKey = &key, pVal = &val;
390  auto f = [=]
391  { return this->putIfAbsent(*pKey,*pVal, lifespan, maxIdle);};
392  return goAsync(f, success, fail);
393  }
405  std::future<V*> putIfAbsentAsync(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit,
406  std::function<V* (V*)> success = nullptr, std::function<V* (std::exception&)> fail = nullptr)
407  {
408  auto pKey = &key, pVal = &val;
409  auto f = [=]
410  { return this->putIfAbsent(*pKey,*pVal, lifespan, lifespanUnit, 0, SECONDS);};
411  return goAsync(f, success, fail);
412  }
426  std::future<V*> putIfAbsentAsync(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit,
427  uint64_t maxIdle, TimeUnit maxIdleUnit, std::function<V* (V*)> success = nullptr,
428  std::function<V* (std::exception&)> fail = nullptr)
429  {
430  auto pKey = &key, pVal = &val;
431  auto f = [=]
432  { return this->putIfAbsent(*pKey,*pVal, lifespan, lifespanUnit, maxIdle, maxIdleUnit);};
433  return goAsync(f, success, fail);
434  }
435 
445  void putAll(const std::map<K, V>& map, uint64_t lifespan = 0, uint64_t maxIdle = 0)
446  {
447  putAll(map, lifespan, SECONDS, maxIdle, SECONDS);
448  }
449 
460  void putAll(const std::map<K, V>& map, uint64_t lifespan, TimeUnit lifespanUnit)
461  {
462  putAll(map, lifespan, lifespanUnit, 0, SECONDS);
463  }
464 
477  void putAll(const std::map<K, V>& map, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle,
478  TimeUnit maxIdleUnit)
479  {
480  uint64_t lifespanMillis = toSeconds(lifespan, lifespanUnit);
481  uint64_t maxIdleMillis = toSeconds(maxIdle, maxIdleUnit);
482 
483  for (typename std::map<K, V>::const_iterator it = map.begin(); it != map.end(); ++it)
484  {
485  put(it->first, it->second, lifespanMillis, maxIdleMillis);
486  }
487  }
488 
500  std::future<void> putAllAsync(const std::map<K, V>& map, uint64_t lifespan = 0, uint64_t maxIdle = 0,
501  std::function<void()> success = nullptr, std::function<void(std::exception&)> fail = nullptr)
502  {
503  auto pMap = map;
504  auto f = [=]
505  { return this->putAll(pMap, lifespan, maxIdle);};
506  return goAsync(f, success, fail);
507  }
508 
520  std::future<void> putAllAsync(const std::map<K, V>& map, uint64_t lifespan, TimeUnit lifespanUnit,
521  std::function<void(void)> success = nullptr, std::function<void(std::exception&)> fail = nullptr)
522  {
523  auto pMap = map;
524  auto f = [=]
525  { this->putAll(pMap, lifespan, lifespanUnit);};
526  return goAsync(f, success, fail);
527  }
528 
542  std::future<void> putAllAsync(const std::map<K, V>& map, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle,
543  TimeUnit maxIdleUnit, std::function<void(void)> success = nullptr,
544  std::function<void(std::exception&)> fail = nullptr)
545  {
546  auto pMap = &map;
547  auto f = [=]
548  { this->putAll(*pMap,lifespan, lifespanUnit, maxIdle, maxIdleUnit);};
549  return goAsync(f, success, fail);
550  }
551 
562  V* replace(const K& key, const V& val, uint64_t lifespan = 0, uint64_t maxIdle = 0)
563  {
564  return replace(key, val, lifespan, SECONDS, maxIdle, SECONDS);
565  }
577  V* replace(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit)
578  {
579  return replace(key, val, lifespan, lifespanUnit, 0, SECONDS);
580  }
593  V* replace(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle,
594  TimeUnit maxIdleUnit)
595  {
596  return (V *) base_replace(&key, &val, toSeconds(lifespan, lifespanUnit), toSeconds(maxIdle, maxIdleUnit));
597  }
609  V* replace(const K& key, const V& oldVal, const V& val, uint64_t lifespan = 0, uint64_t maxIdle = 0)
610  {
611  return replace(key, oldVal, val, lifespan, SECONDS, maxIdle, SECONDS);
612  }
624  V* replace(const K& key, const V& oldVal, const V& val, uint64_t lifespan, TimeUnit lifespanUnit)
625  {
626  return replace(key, oldVal, val, lifespan, lifespanUnit, 0, SECONDS);
627  }
640  V* replace(const K& key, const V& oldVal, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle,
641  TimeUnit maxIdleUnit)
642  {
644  }
645 
657  std::future<V*> replaceAsync(const K& key, const V& val, uint64_t lifespan = 0, uint64_t maxIdle = 0,
658  std::function<V* (V*)> success = nullptr, std::function<V* (std::exception&)> fail = nullptr)
659  {
660  auto pKey = &key, pVal = &val;
661  auto f = [=]
662  { return this->replace(*pKey, *pVal, lifespan, SECONDS, maxIdle, SECONDS);};
663  return goAsync(f, success, fail);
664  }
665 
677  std::future<V*> replaceAsync(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit,
678  std::function<V* (V*)> success = nullptr, std::function<V* (std::exception&)> fail = nullptr)
679  {
680  auto pKey = &key, pVal = &val;
681  auto f = [=]
682  { return this->replace(*pKey, *pVal, lifespan, lifespanUnit, 0, SECONDS);};
683  return goAsync(f, success, fail);
684  }
685 
699  std::future<V*> replaceAsync(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle,
700  TimeUnit maxIdleUnit, std::function<V* (V*)> success = nullptr, std::function<V* (std::exception&)> fail =
701  nullptr)
702  {
703  auto pKey = &key, pVal = &val;
704  auto f = [=]
705  { return this->replace(*pKey, *pVal, lifespan, lifespanUnit, maxIdle, maxIdleUnit);};
706  return goAsync(f, success, fail);
707  }
708 
722  std::future<V*> replaceAsync(const K& key, const V& oldVal, const V& val, uint64_t lifespan = 0, uint64_t maxIdle =
723  0, std::function<V* (V*)> success = nullptr, std::function<V* (std::exception&)> fail = nullptr)
724  {
725  auto f = [=]
726  { return this->replace(key, oldVal, val, lifespan, SECONDS, maxIdle, SECONDS);};
727  return goAsync(f, success, fail);
728  }
729 
743  std::future<V*> replaceAsync(const K& key, const V& oldVal, const V& val, uint64_t lifespan, TimeUnit lifespanUnit,
744  std::function<V* (V*)> success = nullptr, std::function<V* (std::exception&)> fail = nullptr)
745  {
746  auto f = [=]
747  { return this->replace(key, oldVal, val, lifespan, lifespanUnit, 0, SECONDS);};
748  return goAsync(f, success, fail);
749  }
750 
758  V* remove(const K& key)
759  {
760  return (V *) base_remove(&key);
761  }
762 
772  std::future<V*> removeAsync(const K& key, std::function<V* (V*)> success = nullptr,
773  std::function<V* (std::exception&)> fail = nullptr)
774  {
775  auto f = [=]
776  { return this->remove(key);};
777  return goAsync(f, success, fail);
778  }
779 
786  bool containsKey(const K& key)
787  {
788  return base_containsKey(&key);
789  }
790 
795  bool containsValue(const V& val)
796  {
798  }
813  bool replaceWithVersion(const K& key, const V& val, uint64_t version, uint64_t lifespan = 0, uint64_t maxIdle = 0)
814  {
815  return base_replaceWithVersion(&key, &val, version, lifespan, maxIdle);
816  }
817 
831  std::future<bool> replaceWithVersionAsync(const K& key, const V& val, uint64_t version, uint64_t lifespan,
832  uint64_t maxIdle, std::function<bool(bool)> success = nullptr, std::function<bool(std::exception&)> fail =
833  nullptr)
834  {
835  auto f = [=]
836  { return this->replaceWithVersion(key, val, version, lifespan, maxIdle);};
837  return goAsync(f, success, fail);
838  }
839 
858  bool removeWithVersion(const K& key, uint64_t version)
859  {
860  return base_removeWithVersion(&key, version);
861  }
862 
872  std::future<bool> removeWithVersionAsync(const K& key, uint64_t version,
873  std::function<bool(bool)> success = nullptr, std::function<bool(std::exception&)> fail = nullptr)
874  {
875  auto f = [=]
876  { return this->removeWithVersion(key, version);};
877  return goAsync(f, success, fail);
878  }
879 
890  std::pair<std::shared_ptr<V>, VersionedValue> getWithVersion(const K& key)
891  {
892  VersionedValue version;
893  void *value = base_getWithVersion(&key, &version);
894  return std::make_pair(std::shared_ptr<V>((V *) value), version);
895  }
906  std::pair<std::shared_ptr<V>, MetadataValue> getWithMetadata(const K& key)
907  {
908  MetadataValue metadata;
909  void *value = base_getWithMetadata(&key, &metadata);
910  return std::make_pair(std::shared_ptr<V>((V *) value), metadata);
911  }
916  std::map<std::shared_ptr<K>, std::shared_ptr<V> > getBulk()
917  {
918  return getBulk(0);
919  }
924  std::map<std::shared_ptr<K>, std::shared_ptr<V> > getBulk(int nrOfEntries)
925  {
926  std::map<void*, void*> mbuf;
927  std::map<std::shared_ptr<K>, std::shared_ptr<V> > result;
928  base_getBulk(nrOfEntries, mbuf);
929  for (auto it = mbuf.begin(); it != mbuf.end(); ++it)
930  {
931  result[std::shared_ptr<K>((K*) it->first)] = std::shared_ptr<V>((V*) it->second);
932  }
933  return result;
934  }
941  std::vector<unsigned char> execute(const std::string& name, const std::map<std::string, std::string>& args)
942  {
943  return base_execute(name, args);
944  }
945 
952  std::vector<unsigned char> execute(const std::string& name, const std::map<std::vector<char>, std::vector<char> >& args)
953  {
954  return base_execute(name,args);
955  }
956 
962  QueryResponse query(const QueryRequest &qr)
963  {
964  return base_query(qr);
965  }
966 
973  std::vector<unsigned char> query(std::vector<unsigned char> qr, size_t size)
974  {
975  return base_query_char(qr, size);
976  }
977 
982  std::set<std::pair<K, V> > entrySet()
983  {
985  }
993  std::set<std::shared_ptr<K> > keySet()
994  {
995  std::vector<void*> p;
996  base_keySet(0, p);
997 
998  std::set<std::shared_ptr<K> > result;
999  for (size_t i = 0; i < p.size(); ++i)
1000  {
1001  result.insert(std::shared_ptr<K>((K*) p.data()[i]));
1002  }
1003  return result;
1004  }
1010  uint64_t size()
1011  {
1012  return base_size();
1013  }
1019  bool isEmpty()
1020  {
1021  return 0 == size();
1022  }
1027  std::vector<V> values()
1028  {
1030  }
1037  std::map<std::string, std::string> stats()
1038  {
1039  std::map<std::string, std::string> statistics;
1040  base_stats(statistics);
1041  return statistics;
1042  }
1048  void clear()
1049  {
1050  base_clear();
1051  }
1052 
1061  std::future<void> clearAsync(std::function<void(void)> success = nullptr,
1062  std::function<void(std::exception&)> fail = nullptr)
1063  {
1064  auto f = [=]
1065  { this->clear();};
1066  return goAsync(f, success, fail);
1067  }
1068 
1074  void ping()
1075  {
1076  base_ping();
1077  }
1078 
1089  void addClientListener(ClientListener& clientListener, std::vector<std::vector<char> > filterFactoryParams,
1090  std::vector<std::vector<char> > converterFactoryParams, const std::function<void()> &recoveryCallback =
1091  nullptr)
1092  {
1093  base_addClientListener(clientListener, filterFactoryParams, converterFactoryParams, recoveryCallback);
1094  }
1095 
1103  void removeClientListener(ClientListener& clientListener)
1104  {
1105  base_removeClientListener(clientListener);
1106  }
1107 
1108 #if !defined(SWIG) && !defined(SWIGCSHARP)
1109 
1115  {
1116  base_addContinuousQueryListener(cql);
1117  }
1118  template<typename ... Params>
1125  {
1126  base_addContinuousQueryListener(cql);
1127  }
1128 
1134  template<typename ... Params>
1136  {
1137  base_removeClientListener(cql.cl);
1138  }
1139 #endif
1140 
1141  CacheTopologyInfo getCacheTopologyInfo()
1142  {
1143  return base_getCacheTopologyInfo();
1144  }
1152  {
1153  base_withFlags(flags);
1154  return *this;
1155  }
1156 
1163  template <class M = JBossMarshaller>
1165  {
1166  return RemoteExecution<M>(*this);
1167  }
1168 
1169  RemoteCache(const RemoteCache &other) :
1170  RemoteCacheBase(other), keyMarshaller(other.keyMarshaller), valueMarshaller(other.valueMarshaller)
1171  {
1172  setMarshallers(this, &keyMarshall, &valueMarshall, &keyUnmarshall, &valueUnmarshall);
1173  }
1174 
1176  {
1177  RemoteCacheBase::operator=(other);
1178  keyMarshaller = other.keyMarshaller;
1179  valueMarshaller = other.valueMarshaller;
1180  setMarshallers(this, &keyMarshall, &valueMarshall, &keyUnmarshall, &valueUnmarshall);
1181  return *this;
1182  }
1183 protected:
1185  RemoteCacheBase()
1186  {
1187  setMarshallers(this, &keyMarshall, &valueMarshall, &keyUnmarshall, &valueUnmarshall);
1188  }
1189 
1190 private:
1191  uint64_t toSeconds(uint64_t time, TimeUnit unit)
1192  {
1193  uint64_t result;
1194  switch (unit)
1195  {
1196  case NANOSECONDS:
1197  result = (uint64_t) ceil(time / 1000000000.0);
1198  break;
1199  case MICROSECONDS:
1200  result = (uint64_t) ceil(time / 1000000.0);
1201  break;
1202  case MILLISECONDS:
1203  result = (uint64_t) ceil(time / 1000.0);
1204  break;
1205  case SECONDS:
1206  result = time;
1207  break;
1208  case MINUTES:
1209  result = time * 60;
1210  break;
1211  case HOURS:
1212  result = time * 3600;
1213  break;
1214  case DAYS:
1215  result = time * 86400;
1216  break;
1217  default:
1218  std::stringstream ss;
1219  ss << "Unhandled TimeUnit specified: " << unit << ".";
1220  throw std::invalid_argument(ss.str());
1221  }
1222  return result;
1223  }
1224 
1225  // type-hiding and resurrecting support
1226  static void keyMarshall(void *thisp, const void* key, std::vector<char> &buf)
1227  {
1228  ((RemoteCache<K, V> *) thisp)->keyMarshaller->marshall(*(const K *) key, buf);
1229  }
1230  static void valueMarshall(void* thisp, const void* val, std::vector<char> &buf)
1231  {
1232  ((RemoteCache<K, V> *) thisp)->valueMarshaller->marshall(*(const V *) val, buf);
1233  }
1234  static void* keyUnmarshall(void *thisp, const std::vector<char> &buf)
1235  {
1236  return ((RemoteCache<K, V> *) thisp)->keyMarshaller->unmarshall(buf);
1237  }
1238  static void* valueUnmarshall(void* thisp, const std::vector<char> &buf)
1239  {
1240  return ((RemoteCache<K, V> *) thisp)->valueMarshaller->unmarshall(buf);
1241  }
1242 
1243  std::shared_ptr<Marshaller<K> > keyMarshaller;
1244  std::shared_ptr<Marshaller<V> > valueMarshaller;
1245 
1246  friend class RemoteCacheManager;
1247 };
1248 }
1249 } // namespace
1250 
1251 #endif /* ISPN_HOTROD_REMOTECACHE_H */
void putAll(const std::map< K, V > &map, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit)
Definition: RemoteCache.h:477
std::future< V * > putAsync(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit, std::function< V *(V *)> success=nullptr, std::function< V *(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:298
std::map< std::shared_ptr< K >, std::shared_ptr< V > > getBulk(int nrOfEntries)
Definition: RemoteCache.h:924
std::future< bool > replaceWithVersionAsync(const K &key, const V &val, uint64_t version, uint64_t lifespan, uint64_t maxIdle, std::function< bool(bool)> success=nullptr, std::function< bool(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:831
V * putIfAbsent(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit)
Definition: RemoteCache.h:354
std::future< void > putAllAsync(const std::map< K, V > &map, uint64_t lifespan=0, uint64_t maxIdle=0, std::function< void()> success=nullptr, std::function< void(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:500
std::future< V * > putIfAbsentAsync(const K &key, const V &val, uint64_t lifespan=0, uint64_t maxIdle=0, std::function< V *(V *)> success=nullptr, std::function< V *(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:386
std::vector< unsigned char > query(std::vector< unsigned char > qr, size_t size)
Definition: RemoteCache.h:973
void removeContinuousQueryListener(ContinuousQueryListener< Params...> &cql)
Definition: RemoteCache.h:1135
V * put(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit)
Definition: RemoteCache.h:262
std::string getName()
Definition: RemoteCache.h:111
std::pair< std::shared_ptr< V >, VersionedValue > getWithVersion(const K &key)
Definition: RemoteCache.h:890
std::set< std::pair< K, V > > entrySet()
Definition: RemoteCache.h:982
static const char * getProtocolVersionCString()
Definition: Version.h:32
std::map< std::shared_ptr< K >, std::shared_ptr< V > > getAll(const std::set< K > &keySet)
Definition: RemoteCache.h:155
void addContinuousQueryListener(ContinuousQueryListener< K, V, Params...> &cql)
Definition: RemoteCache.h:1124
bool containsKey(const K &key)
Definition: RemoteCache.h:786
std::future< V * > replaceAsync(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit, std::function< V *(V *)> success=nullptr, std::function< V *(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:699
std::map< std::string, std::string > stats()
Definition: RemoteCache.h:1037
std::future< V * > putIfAbsentAsync(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit, std::function< V *(V *)> success=nullptr, std::function< V *(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:426
V * replace(const K &key, const V &oldVal, const V &val, uint64_t lifespan=0, uint64_t maxIdle=0)
Definition: RemoteCache.h:609
std::set< std::shared_ptr< K > > keySet()
Definition: RemoteCache.h:993
void putAll(const std::map< K, V > &map, uint64_t lifespan=0, uint64_t maxIdle=0)
Definition: RemoteCache.h:445
RemoteExecution< M > getRemoteExecution()
Definition: RemoteCache.h:1164
RemoteCache< K, V > & operator=(const RemoteCache &other)
Definition: RemoteCache.h:1175
std::future< void > putAllAsync(const std::map< K, V > &map, uint64_t lifespan, TimeUnit lifespanUnit, std::function< void(void)> success=nullptr, std::function< void(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:520
std::vector< V > values()
Definition: RemoteCache.h:1027
void addContinuousQueryListener(ContinuousQueryListener< K, V > &cql)
Definition: RemoteCache.h:1114
V * putIfAbsent(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit)
Definition: RemoteCache.h:370
std::map< std::shared_ptr< K >, std::shared_ptr< V > > getBulk()
Definition: RemoteCache.h:916
std::future< bool > removeWithVersionAsync(const K &key, uint64_t version, std::function< bool(bool)> success=nullptr, std::function< bool(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:872
Definition: CacheClientListener.h:28
Definition: TimeUnit.h:14
Definition: TimeUnit.h:18
V * putIfAbsent(const K &key, const V &val, uint64_t lifespan=0, uint64_t maxIdle=0)
Definition: RemoteCache.h:340
Definition: TimeUnit.h:15
std::future< V * > putAsync(const K &key, const V &val, uint64_t lifespan=0, uint64_t maxIdle=0, std::function< V *(V *)> success=nullptr, std::function< V *(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:278
V * replace(const K &key, const V &oldVal, const V &val, uint64_t lifespan, TimeUnit lifespanUnit)
Definition: RemoteCache.h:624
std::future< V * > putIfAbsentAsync(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit, std::function< V *(V *)> success=nullptr, std::function< V *(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:405
uint64_t size()
Definition: RemoteCache.h:1010
std::future< V * > getAsync(const K &key, std::function< V *(V *)> success=nullptr, std::function< V *(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:185
void removeClientListener(ClientListener &clientListener)
Definition: RemoteCache.h:1103
std::future< V * > replaceAsync(const K &key, const V &oldVal, const V &val, uint64_t lifespan=0, uint64_t maxIdle=0, std::function< V *(V *)> success=nullptr, std::function< V *(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:722
RemoteCache()
Definition: RemoteCache.h:1184
void addClientListener(ClientListener &clientListener, std::vector< std::vector< char > > filterFactoryParams, std::vector< std::vector< char > > converterFactoryParams, const std::function< void()> &recoveryCallback=nullptr)
Definition: RemoteCache.h:1089
std::vector< unsigned char > execute(const std::string &name, const std::map< std::string, std::string > &args)
Definition: RemoteCache.h:941
std::future< V * > replaceAsync(const K &key, const V &oldVal, const V &val, uint64_t lifespan, TimeUnit lifespanUnit, std::function< V *(V *)> success=nullptr, std::function< V *(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:743
CacheTopologyInfo getCacheTopologyInfo()
Definition: RemoteCache.h:1141
void clear()
Definition: RemoteCache.h:1048
bool isEmpty()
Definition: RemoteCache.h:1019
std::future< void > clearAsync(std::function< void(void)> success=nullptr, std::function< void(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:1061
std::future< V * > replaceAsync(const K &key, const V &val, uint64_t lifespan=0, uint64_t maxIdle=0, std::function< V *(V *)> success=nullptr, std::function< V *(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:657
V * put(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit)
Definition: RemoteCache.h:236
RemoteCache< K, V > & withFlags(Flag flags)
Definition: RemoteCache.h:1151
RemoteCache(const RemoteCache &other)
Definition: RemoteCache.h:1169
bool replaceWithVersion(const K &key, const V &val, uint64_t version, uint64_t lifespan=0, uint64_t maxIdle=0)
Definition: RemoteCache.h:813
std::string getVersion()
Definition: RemoteCache.h:121
Definition: RemoteCacheManager.h:38
Definition: TimeUnit.h:17
std::string getProtocolVersion()
Definition: RemoteCache.h:131
std::future< void > putAllAsync(const std::map< K, V > &map, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit, std::function< void(void)> success=nullptr, std::function< void(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:542
std::future< V * > removeAsync(const K &key, std::function< V *(V *)> success=nullptr, std::function< V *(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:772
V * replace(const K &key, const V &oldVal, const V &val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit)
Definition: RemoteCache.h:640
Definition: ClientListener.h:35
V * replace(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit)
Definition: RemoteCache.h:593
void ping()
Definition: RemoteCache.h:1074
std::future< V * > putAsync(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit, std::function< V *(V *)> success=nullptr, std::function< V *(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:320
QueryResponse query(const QueryRequest &qr)
Definition: RemoteCache.h:962
Definition: ContinuousQueryListener.h:34
static const char * getVersionCString()
Definition: Version.h:41
TimeUnit
Definition: TimeUnit.h:13
bool containsValue(const V &val)
Definition: RemoteCache.h:795
V * replace(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit)
Definition: RemoteCache.h:577
Definition: TimeUnit.h:16
Definition: TimeUnit.h:19
Definition: TimeUnit.h:20
Definition: MetadataValue.h:9
V * replace(const K &key, const V &val, uint64_t lifespan=0, uint64_t maxIdle=0)
Definition: RemoteCache.h:562
std::vector< unsigned char > execute(const std::string &name, const std::map< std::vector< char >, std::vector< char > > &args)
Definition: RemoteCache.h:952
std::pair< std::shared_ptr< V >, MetadataValue > getWithMetadata(const K &key)
Definition: RemoteCache.h:906
Flag
Definition: Flag.h:7
std::future< V * > replaceAsync(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit, std::function< V *(V *)> success=nullptr, std::function< V *(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:677
Definition: RemoteExecution.h:29
Definition: VersionedValue.h:9
V * put(const K &key, const V &val, uint64_t lifespan=0, uint64_t maxIdle=0)
Definition: RemoteCache.h:213
void putAll(const std::map< K, V > &map, uint64_t lifespan, TimeUnit lifespanUnit)
Definition: RemoteCache.h:460
bool removeWithVersion(const K &key, uint64_t version)
Definition: RemoteCache.h:858