Infinispan HotRod C++ Client 9.2.0.Final
Loading...
Searching...
No Matches
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
29namespace infinispan
30{
31namespace hotrod
32{
33
64template<class K, class V> class RemoteCache: private RemoteCacheBase
65{
66private:
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
104public:
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
148private:
149 V* get_async(const K& key)
150 {
151 return (V *) base_get(&key);
152 }
153
154public:
155
163 std::map<std::shared_ptr<K>, std::shared_ptr<V> > getAll(const std::set<K>& keySet)
164 {
165 std::set<std::vector<char> > keySetMarshalled;
166 for (auto item = keySet.begin(); item != keySet.end(); item++)
167 {
168 std::vector<char> v;
169 this->keyMarshaller->marshall(*item, v);
170 keySetMarshalled.insert(v);
171 }
172 auto marshalledResult = base_getAll(keySetMarshalled);
173 std::map<std::shared_ptr<K>, std::shared_ptr<V> > result;
174 for (auto item : marshalledResult)
175 {
176 std::shared_ptr<K> rk(this->keyMarshaller->unmarshall(item.first));
177 std::shared_ptr<V> rv(this->keyMarshaller->unmarshall(item.second));
178 result[rk] = rv;
179 }
180 return result;
181 }
182
193 std::future<V*> getAsync(const K& key, std::function<V* (V*)> success = nullptr,
194 std::function<V* (std::exception&)> fail = nullptr)
195 {
196 const K* pKey = &key;
197 auto currTx = transactionManager.getCurrentTransaction();
198 std::function<V* (void)> f = [=]
199 { return (V*)this->base_get(pKey, currTx);};
200 return goAsync(f, success, fail);
201 }
202
222 V* put(const K& key, const V& val, uint64_t lifespan = 0, uint64_t maxIdle = 0)
223 {
224 return put(key, val, lifespan, SECONDS, maxIdle, SECONDS);
225 }
245 V* put(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit)
246 {
247 return put(key, val, lifespan, lifespanUnit, 0, SECONDS);
248 }
249
271 V* put(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit)
272 {
273 return (V *) base_put(&key, &val, toSeconds(lifespan, lifespanUnit), toSeconds(maxIdle, maxIdleUnit));
274 }
275
287 std::future<V*> putAsync(const K& key, const V& val, uint64_t lifespan = 0, uint64_t maxIdle = 0,
288 std::function<V* (V*)> success = nullptr, std::function<V* (std::exception&)> fail = nullptr)
289 {
290 const K* pKey = &key;
291 const V* pVal = &val;
292 auto currTx = transactionManager.getCurrentTransaction();
293 std::function<V* (void)> f = [=]
294 { return (V*)this->base_put(pKey, pVal, lifespan, maxIdle, currTx);};
295 return goAsync(f, success, fail);
296 }
297
309 std::future<V*> putAsync(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit,
310 std::function<V* (V*)> success = nullptr, std::function<V* (std::exception&)> fail = nullptr)
311 {
312 const K* pKey = &key;
313 const V* pVal = &val;
314 auto currTx = transactionManager.getCurrentTransaction();
315 std::function<V* (void)> f = [=]
316 { return (V*)this->base_put(pKey, pVal, lifespan, lifespanUnit, currTx);};
317 return goAsync(f, success, fail);
318 }
319
333 std::future<V*> putAsync(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle,
334 TimeUnit maxIdleUnit, std::function<V* (V*)> success = nullptr, std::function<V* (std::exception&)> fail =
335 nullptr)
336 {
337 const K* pKey = &key;
338 const V* pVal = &val;
339 auto currTx = transactionManager.getCurrentTransaction();
340 std::function<V* (void)> f = [=]
341 { return (V*)this->base_put(pKey, pVal, toSeconds(lifespan, lifespanUnit), toSeconds(maxIdle, maxIdleUnit), currTx); };
342 return goAsync(f, success, fail);
343 }
344
355 V* putIfAbsent(const K& key, const V& val, uint64_t lifespan = 0, uint64_t maxIdle = 0)
356 {
357 return putIfAbsent(key, val, lifespan, SECONDS, maxIdle, SECONDS);
358 }
369 V* putIfAbsent(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit)
370 {
371 return putIfAbsent(key, val, lifespan, lifespanUnit, 0, SECONDS);
372 }
385 V* putIfAbsent(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle,
386 TimeUnit maxIdleUnit)
387 {
388 return (V *) base_putIfAbsent(&key, &val, toSeconds(lifespan, lifespanUnit), toSeconds(maxIdle, maxIdleUnit));
389 }
401 std::future<V*> putIfAbsentAsync(const K& key, const V& val, uint64_t lifespan = 0, uint64_t maxIdle = 0,
402 std::function<V* (V*)> success = nullptr, std::function<V* (std::exception&)> fail = nullptr)
403 {
404 const K* pKey = &key;
405 const V* pVal = &val;
406 auto currTx = transactionManager.getCurrentTransaction();
407 std::function<V* (void)> f = [=]
408 { return (V*)this->base_putIfAbsent(pKey,pVal, lifespan, maxIdle, currTx);};
409 return goAsync(f, success, fail);
410 }
422 std::future<V*> putIfAbsentAsync(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit,
423 std::function<V* (V*)> success = nullptr, std::function<V* (std::exception&)> fail = nullptr)
424 {
425 const K* pKey = &key;
426 const V* pVal = &val;
427 auto currTx = transactionManager.getCurrentTransaction();
428 std::function<V* (void)> f = [=]
429 { return (V*)this->base_putIfAbsent(pKey, pVal, toSeconds(lifespan, lifespanUnit), toSeconds(0, SECONDS), currTx); };
430 return goAsync(f, success, fail);
431 }
445 std::future<V*> putIfAbsentAsync(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit,
446 uint64_t maxIdle, TimeUnit maxIdleUnit, std::function<V* (V*)> success = nullptr,
447 std::function<V* (std::exception&)> fail = nullptr)
448 {
449 const K* pKey = &key;
450 const V* pVal = &val;
451 auto currTx = transactionManager.getCurrentTransaction();
452 std::function<V* (void)> f = [=]
453 { return (V*)this->base_putIfAbsent(pKey,pVal, toSeconds(lifespan, lifespanUnit), toSeconds(maxIdle, maxIdleUnit), currTx);};
454 return goAsync(f, success, fail);
455 }
456
466 void putAll(const std::map<K, V>& map, uint64_t lifespan = 0, uint64_t maxIdle = 0)
467 {
468 putAll(map, lifespan, SECONDS, maxIdle, SECONDS);
469 }
470
481 void putAll(const std::map<K, V>& map, uint64_t lifespan, TimeUnit lifespanUnit)
482 {
483 putAll(map, lifespan, lifespanUnit, 0, SECONDS);
484 }
485
498 void putAll(const std::map<K, V>& map, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle,
499 TimeUnit maxIdleUnit)
500 {
501 uint64_t lifespanMillis = toSeconds(lifespan, lifespanUnit);
502 uint64_t maxIdleMillis = toSeconds(maxIdle, maxIdleUnit);
503 std::map<const void*, const void*> tmpMap;
504 for (auto& it : map)
505 {
506 tmpMap[(const void *)&it.first] = (const void *)&it.second;
507 }
508 base_putAll(tmpMap, lifespanMillis, maxIdleMillis);
509 }
510
522 std::future<void> putAllAsync(const std::map<K, V>& map, uint64_t lifespan = 0, uint64_t maxIdle = 0,
523 std::function<void()> success = nullptr, std::function<void(std::exception&)> fail = nullptr)
524 {
525 auto pMap = map;
526 auto f = [=]
527 { return this->putAll(pMap, lifespan, maxIdle);};
528 return goAsync(f, success, fail);
529 }
530
542 std::future<void> putAllAsync(const std::map<K, V>& map, uint64_t lifespan, TimeUnit lifespanUnit,
543 std::function<void(void)> success = nullptr, std::function<void(std::exception&)> fail = nullptr)
544 {
545 auto pMap = map;
546 auto f = [=]
547 { this->putAll(pMap, lifespan, lifespanUnit);};
548 return goAsync(f, success, fail);
549 }
550
564 std::future<void> putAllAsync(const std::map<K, V>& map, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle,
565 TimeUnit maxIdleUnit, std::function<void(void)> success = nullptr,
566 std::function<void(std::exception&)> fail = nullptr)
567 {
568 auto pMap = &map;
569 auto f = [=]
570 { this->putAll(*pMap,lifespan, lifespanUnit, maxIdle, maxIdleUnit);};
571 return goAsync(f, success, fail);
572 }
573
584 V* replace(const K& key, const V& val, uint64_t lifespan = 0, uint64_t maxIdle = 0)
585 {
586 return replace(key, val, lifespan, SECONDS, maxIdle, SECONDS);
587 }
599 V* replace(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit)
600 {
601 return replace(key, val, lifespan, lifespanUnit, 0, SECONDS);
602 }
615 V* replace(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle,
616 TimeUnit maxIdleUnit)
617 {
618 return (V *) base_replace(&key, &val, toSeconds(lifespan, lifespanUnit), toSeconds(maxIdle, maxIdleUnit));
619 }
631 V* replace(const K& key, const V& oldVal, const V& val, uint64_t lifespan = 0, uint64_t maxIdle = 0)
632 {
633 return replace(key, oldVal, val, lifespan, SECONDS, maxIdle, SECONDS);
634 }
646 V* replace(const K& key, const V& oldVal, const V& val, uint64_t lifespan, TimeUnit lifespanUnit)
647 {
648 return replace(key, oldVal, val, lifespan, lifespanUnit, 0, SECONDS);
649 }
662 V* replace(const K& key, const V& oldVal, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle,
663 TimeUnit maxIdleUnit)
664 {
666 }
667
679 std::future<V*> replaceAsync(const K& key, const V& val, uint64_t lifespan = 0, uint64_t maxIdle = 0,
680 std::function<V* (V*)> success = nullptr, std::function<V* (std::exception&)> fail = nullptr)
681 {
682 auto pKey = &key, pVal = &val;
683 auto f = [=]
684 { return this->replace(*pKey, *pVal, lifespan, SECONDS, maxIdle, SECONDS);};
685 return goAsync(f, success, fail);
686 }
687
699 std::future<V*> replaceAsync(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit,
700 std::function<V* (V*)> success = nullptr, std::function<V* (std::exception&)> fail = nullptr)
701 {
702 auto pKey = &key, pVal = &val;
703 auto f = [=]
704 { return this->replace(*pKey, *pVal, lifespan, lifespanUnit, 0, SECONDS);};
705 return goAsync(f, success, fail);
706 }
707
721 std::future<V*> replaceAsync(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle,
722 TimeUnit maxIdleUnit, std::function<V* (V*)> success = nullptr, std::function<V* (std::exception&)> fail =
723 nullptr)
724 {
725 auto pKey = &key, pVal = &val;
726 auto f = [=]
727 { return this->replace(*pKey, *pVal, lifespan, lifespanUnit, maxIdle, maxIdleUnit);};
728 return goAsync(f, success, fail);
729 }
730
744 std::future<V*> replaceAsync(const K& key, const V& oldVal, const V& val, uint64_t lifespan = 0, uint64_t maxIdle =
745 0, std::function<V* (V*)> success = nullptr, std::function<V* (std::exception&)> fail = nullptr)
746 {
747 auto f = [=]
748 { return this->replace(key, oldVal, val, lifespan, SECONDS, maxIdle, SECONDS);};
749 return goAsync(f, success, fail);
750 }
751
765 std::future<V*> replaceAsync(const K& key, const V& oldVal, const V& val, uint64_t lifespan, TimeUnit lifespanUnit,
766 std::function<V* (V*)> success = nullptr, std::function<V* (std::exception&)> fail = nullptr)
767 {
768 auto f = [=]
769 { return this->replace(key, oldVal, val, lifespan, lifespanUnit, 0, SECONDS);};
770 return goAsync(f, success, fail);
771 }
772
780 V* remove(const K& key)
781 {
782 return (V *) base_remove(&key);
783 }
784
794 std::future<V*> removeAsync(const K& key, std::function<V* (V*)> success = nullptr,
795 std::function<V* (std::exception&)> fail = nullptr)
796 {
797 auto f = [=]
798 { return this->remove(key);};
799 return goAsync(f, success, fail);
800 }
801
808 bool containsKey(const K& key)
809 {
810 return base_containsKey(&key);
811 }
812
817 bool containsValue(const V& val)
818 {
820 }
835 bool replaceWithVersion(const K& key, const V& val, uint64_t version, uint64_t lifespan = 0, uint64_t maxIdle = 0)
836 {
837 return base_replaceWithVersion(&key, &val, version, lifespan, maxIdle);
838 }
839
853 std::future<bool> replaceWithVersionAsync(const K& key, const V& val, uint64_t version, uint64_t lifespan,
854 uint64_t maxIdle, std::function<bool(bool)> success = nullptr, std::function<bool(std::exception&)> fail =
855 nullptr)
856 {
857 auto f = [=]
858 { return this->replaceWithVersion(key, val, version, lifespan, maxIdle);};
859 return goAsync(f, success, fail);
860 }
861
880 bool removeWithVersion(const K& key, uint64_t version)
881 {
882 return base_removeWithVersion(&key, version);
883 }
884
894 std::future<bool> removeWithVersionAsync(const K& key, uint64_t version,
895 std::function<bool(bool)> success = nullptr, std::function<bool(std::exception&)> fail = nullptr)
896 {
897 auto f = [=]
898 { return this->removeWithVersion(key, version);};
899 return goAsync(f, success, fail);
900 }
901
912 std::pair<std::shared_ptr<V>, VersionedValue> getWithVersion(const K& key)
913 {
914 VersionedValue version;
915 void *value = base_getWithVersion(&key, &version);
916 return std::make_pair(std::shared_ptr<V>((V *) value), version);
917 }
928 std::pair<std::shared_ptr<V>, MetadataValue> getWithMetadata(const K& key)
929 {
930 MetadataValue metadata;
931 void *value = base_getWithMetadata(&key, &metadata);
932 return std::make_pair(std::shared_ptr<V>((V *) value), metadata);
933 }
938 std::map<std::shared_ptr<K>, std::shared_ptr<V> > getBulk()
939 {
940 return getBulk(0);
941 }
946 std::map<std::shared_ptr<K>, std::shared_ptr<V> > getBulk(int nrOfEntries)
947 {
948 std::map<void*, void*> mbuf;
949 std::map<std::shared_ptr<K>, std::shared_ptr<V> > result;
950 base_getBulk(nrOfEntries, mbuf);
951 for (auto it = mbuf.begin(); it != mbuf.end(); ++it)
952 {
953 result[std::shared_ptr<K>((K*) it->first)] = std::shared_ptr<V>((V*) it->second);
954 }
955 return result;
956 }
963 std::vector<unsigned char> execute(const std::string& name, const std::map<std::string, std::string>& args)
964 {
965 return base_execute(name, args);
966 }
967
974 std::vector<unsigned char> execute(const std::string& name, const std::map<std::vector<char>, std::vector<char> >& args)
975 {
976 return base_execute(name,args);
977 }
978
984 QueryResponse query(const QueryRequest &qr)
985 {
986 return base_query(qr);
987 }
988
995 std::vector<unsigned char> query(std::vector<unsigned char> qr, size_t size)
996 {
997 return base_query_char(qr, size);
998 }
999
1004 std::set<std::pair<K, V> > entrySet()
1005 {
1007 }
1015 std::set<std::shared_ptr<K> > keySet()
1016 {
1017 std::vector<void*> p;
1018 base_keySet(0, p);
1019
1020 std::set<std::shared_ptr<K> > result;
1021 for (size_t i = 0; i < p.size(); ++i)
1022 {
1023 result.insert(std::shared_ptr<K>((K*) p.data()[i]));
1024 }
1025 return result;
1026 }
1032 uint64_t size()
1033 {
1034 return base_size();
1035 }
1041 bool isEmpty()
1042 {
1043 return 0 == size();
1044 }
1049 std::vector<V> values()
1050 {
1052 }
1059 std::map<std::string, std::string> stats()
1060 {
1061 std::map<std::string, std::string> statistics;
1062 base_stats(statistics);
1063 return statistics;
1064 }
1070 void clear()
1071 {
1072 base_clear();
1073 }
1074
1083 std::future<void> clearAsync(std::function<void(void)> success = nullptr,
1084 std::function<void(std::exception&)> fail = nullptr)
1085 {
1086 auto f = [=]
1087 { this->clear();};
1088 return goAsync(f, success, fail);
1089 }
1090
1096 void ping()
1097 {
1098 base_ping();
1099 }
1100
1111 void addClientListener(ClientListener& clientListener, std::vector<std::vector<char> > filterFactoryParams,
1112 std::vector<std::vector<char> > converterFactoryParams, const std::function<void()> &recoveryCallback =
1113 nullptr)
1114 {
1115 base_addClientListener(clientListener, filterFactoryParams, converterFactoryParams, recoveryCallback);
1116 }
1117
1126 {
1127 base_removeClientListener(clientListener);
1128 }
1129
1130#if !defined(SWIG) && !defined(SWIGCSHARP)
1137 {
1138 base_addContinuousQueryListener(cql);
1139 }
1140 template<typename ... Params>
1147 {
1148 base_addContinuousQueryListener(cql);
1149 }
1150
1156 template<typename ... Params>
1158 {
1159 base_removeClientListener(cql.cl);
1160 }
1161#endif
1162
1163 CacheTopologyInfo getCacheTopologyInfo()
1164 {
1165 return base_getCacheTopologyInfo();
1166 }
1174 {
1175 base_withFlags(flags);
1176 return *this;
1177 }
1178
1185 template <class M = JBossMarshaller>
1187 {
1188 return RemoteExecution<M>(*this);
1189 }
1190
1191 RemoteCache(const RemoteCache &other) :
1192 RemoteCacheBase(other), keyMarshaller(other.keyMarshaller), valueMarshaller(other.valueMarshaller)
1193 {
1194 setMarshallers(this, &keyMarshall, &valueMarshall, &keyUnmarshall, &valueUnmarshall);
1195 valueCopyConstructor = [](const void* src) { V* v = new V(*static_cast<const V*>(src)); return (void*) v; };
1196 valueDestructor = [](const void* obj) { delete static_cast<const V*>(obj); };
1197 }
1198
1207 RemoteCache rc(*this);
1208 rc.keyMarshaller = (df->keyMarshaller != nullptr) ? df->keyMarshaller : this->keyMarshaller;
1209 rc.valueMarshaller = (df->valueMarshaller != nullptr) ? df->valueMarshaller : this->valueMarshaller;
1210 rc.cloneImplWithDataFormat(df);
1211 return rc;
1212 }
1213
1223 template <class K1, class V1> RemoteCache<K1,V1> withDataFormat(DataFormat<K1,V1>* df) {
1224 RemoteCache<K1,V1> rc((RemoteCacheBase&)*this);
1225 rc.keyMarshaller = df->keyMarshaller;
1226 rc.valueMarshaller = df->valueMarshaller;
1227 rc.cloneImplWithDataFormat(df);
1228 return rc;
1229 }
1230
1231protected:
1232
1233 RemoteCache(const RemoteCacheBase& rcb) : RemoteCacheBase(rcb){
1234 setRemoteCachePtr(this);
1235 }
1236
1237 RemoteCache(TransactionManager& tm, TransactionTable& tt, bool forceReturnValue, bool transactional) :
1238 RemoteCacheBase(tm, tt, forceReturnValue, transactional)
1239 {
1240 valueCopyConstructor = [](const void* src) { V* v = new V(*static_cast<const V*>(src)); return (void*) v; };
1241 valueDestructor = [](const void* obj) { delete static_cast<const V*>(obj); };
1242 setMarshallers(this, &keyMarshall, &valueMarshall, &keyUnmarshall, &valueUnmarshall);
1243 }
1244
1245private:
1246 uint64_t toSeconds(uint64_t time, TimeUnit unit)
1247 {
1248 uint64_t result;
1249 switch (unit)
1250 {
1251 case NANOSECONDS:
1252 result = (uint64_t) ceil(time / 1000000000.0);
1253 break;
1254 case MICROSECONDS:
1255 result = (uint64_t) ceil(time / 1000000.0);
1256 break;
1257 case MILLISECONDS:
1258 result = (uint64_t) ceil(time / 1000.0);
1259 break;
1260 case SECONDS:
1261 result = time;
1262 break;
1263 case MINUTES:
1264 result = time * 60;
1265 break;
1266 case HOURS:
1267 result = time * 3600;
1268 break;
1269 case DAYS:
1270 result = time * 86400;
1271 break;
1272 default:
1273 std::stringstream ss;
1274 ss << "Unhandled TimeUnit specified: " << unit << ".";
1275 throw std::invalid_argument(ss.str());
1276 }
1277 return result;
1278 }
1279
1280 // type-hiding and resurrecting support
1281 static void keyMarshall(void *thisp, const void* key, std::vector<char> &buf)
1282 {
1283 ((RemoteCache<K, V> *) thisp)->keyMarshaller->marshall(*(const K *) key, buf);
1284 }
1285 static void valueMarshall(void* thisp, const void* val, std::vector<char> &buf)
1286 {
1287 ((RemoteCache<K, V> *) thisp)->valueMarshaller->marshall(*(const V *) val, buf);
1288 }
1289 static void* keyUnmarshall(void *thisp, const std::vector<char> &buf)
1290 {
1291 return ((RemoteCache<K, V> *) thisp)->keyMarshaller->unmarshall(buf);
1292 }
1293 static void* valueUnmarshall(void* thisp, const std::vector<char> &buf)
1294 {
1295 return ((RemoteCache<K, V> *) thisp)->valueMarshaller->unmarshall(buf);
1296 }
1297
1298 std::shared_ptr<Marshaller<K> > keyMarshaller;
1299 std::shared_ptr<Marshaller<V> > valueMarshaller;
1300
1302 template <class K1, class V1> friend class RemoteCache;
1303};
1304}
1305} // namespace
1306
1307#endif /* ISPN_HOTROD_REMOTECACHE_H */
Definition: MetadataValue.h:10
Definition: RemoteCacheManager.h:44
Definition: RemoteCache.h:65
V * get(const K &key)
Definition: RemoteCache.h:143
void removeClientListener(ClientListener &clientListener)
Definition: RemoteCache.h:1125
void removeContinuousQueryListener(ContinuousQueryListener< Params... > &cql)
Definition: RemoteCache.h:1157
bool containsKey(const K &key)
Definition: RemoteCache.h:808
RemoteCache(const RemoteCacheBase &rcb)
Definition: RemoteCache.h:1233
void ping()
Definition: RemoteCache.h:1096
void addContinuousQueryListener(ContinuousQueryListener< K, V, Params... > &cql)
Definition: RemoteCache.h:1146
std::map< std::string, std::string > stats()
Definition: RemoteCache.h:1059
std::pair< std::shared_ptr< V >, MetadataValue > getWithMetadata(const K &key)
Definition: RemoteCache.h:928
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:309
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:564
RemoteCache(const RemoteCache &other)
Definition: RemoteCache.h:1191
std::future< V * > getAsync(const K &key, std::function< V *(V *)> success=nullptr, std::function< V *(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:193
void putAll(const std::map< K, V > &map, uint64_t lifespan, TimeUnit lifespanUnit)
Definition: RemoteCache.h:481
std::vector< unsigned char > query(std::vector< unsigned char > qr, size_t size)
Definition: RemoteCache.h:995
void clear()
Definition: RemoteCache.h:1070
std::set< std::shared_ptr< K > > keySet()
Definition: RemoteCache.h:1015
V * putIfAbsent(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit)
Definition: RemoteCache.h:369
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:333
V * replace(const K &key, const V &oldVal, const V &val, uint64_t lifespan=0, uint64_t maxIdle=0)
Definition: RemoteCache.h:631
V * putIfAbsent(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit)
Definition: RemoteCache.h:385
std::string getProtocolVersion()
Definition: RemoteCache.h:131
bool isEmpty()
Definition: RemoteCache.h:1041
V * replace(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit)
Definition: RemoteCache.h:615
void addContinuousQueryListener(ContinuousQueryListener< K, V > &cql)
Definition: RemoteCache.h:1136
QueryResponse query(const QueryRequest &qr)
Definition: RemoteCache.h:984
std::future< V * > removeAsync(const K &key, std::function< V *(V *)> success=nullptr, std::function< V *(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:794
RemoteExecution< M > getRemoteExecution()
Definition: RemoteCache.h:1186
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:522
RemoteCache(TransactionManager &tm, TransactionTable &tt, bool forceReturnValue, bool transactional)
Definition: RemoteCache.h:1237
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:679
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:542
V * replace(const K &key, const V &val, uint64_t lifespan=0, uint64_t maxIdle=0)
Definition: RemoteCache.h:584
bool removeWithVersion(const K &key, uint64_t version)
Definition: RemoteCache.h:880
V * put(const K &key, const V &val, uint64_t lifespan=0, uint64_t maxIdle=0)
Definition: RemoteCache.h:222
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:894
V * put(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit)
Definition: RemoteCache.h:271
V * put(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit)
Definition: RemoteCache.h:245
std::map< std::shared_ptr< K >, std::shared_ptr< V > > getBulk(int nrOfEntries)
Definition: RemoteCache.h:946
std::pair< std::shared_ptr< V >, VersionedValue > getWithVersion(const K &key)
Definition: RemoteCache.h:912
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:744
void putAll(const std::map< K, V > &map, uint64_t lifespan=0, uint64_t maxIdle=0)
Definition: RemoteCache.h:466
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:1111
void putAll(const std::map< K, V > &map, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit)
Definition: RemoteCache.h:498
uint64_t size()
Definition: RemoteCache.h:1032
std::map< std::shared_ptr< K >, std::shared_ptr< V > > getAll(const std::set< K > &keySet)
Definition: RemoteCache.h:163
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:287
std::future< void > clearAsync(std::function< void(void)> success=nullptr, std::function< void(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:1083
V * replace(const K &key, const V &oldVal, const V &val, uint64_t lifespan, TimeUnit lifespanUnit)
Definition: RemoteCache.h:646
V * replace(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit)
Definition: RemoteCache.h:599
std::string getName()
Definition: RemoteCache.h:111
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:853
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:765
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:699
RemoteCache withDataFormat(DataFormat< K, V > *df)
Definition: RemoteCache.h:1206
std::set< std::pair< K, V > > entrySet()
Definition: RemoteCache.h:1004
bool containsValue(const V &val)
Definition: RemoteCache.h:817
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:445
V * remove(const K &key)
Definition: RemoteCache.h:780
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:401
CacheTopologyInfo getCacheTopologyInfo()
Definition: RemoteCache.h:1163
std::vector< V > values()
Definition: RemoteCache.h:1049
V * replace(const K &key, const V &oldVal, const V &val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit)
Definition: RemoteCache.h:662
V * putIfAbsent(const K &key, const V &val, uint64_t lifespan=0, uint64_t maxIdle=0)
Definition: RemoteCache.h:355
std::vector< unsigned char > execute(const std::string &name, const std::map< std::vector< char >, std::vector< char > > &args)
Definition: RemoteCache.h:974
std::string getVersion()
Definition: RemoteCache.h:121
std::vector< unsigned char > execute(const std::string &name, const std::map< std::string, std::string > &args)
Definition: RemoteCache.h:963
RemoteCache< K1, V1 > withDataFormat(DataFormat< K1, V1 > *df)
Definition: RemoteCache.h:1223
bool replaceWithVersion(const K &key, const V &val, uint64_t version, uint64_t lifespan=0, uint64_t maxIdle=0)
Definition: RemoteCache.h:835
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:422
std::map< std::shared_ptr< K >, std::shared_ptr< V > > getBulk()
Definition: RemoteCache.h:938
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:721
RemoteCache< K, V > & withFlags(Flag flags)
Definition: RemoteCache.h:1173
Definition: RemoteExecution.h:29
Definition: TransactionManager.h:25
Definition: Transactions.h:174
static const char * getVersionCString()
Definition: Version.h:41
static const char * getProtocolVersionCString()
Definition: Version.h:32
Definition: VersionedValue.h:10
Definition: ClientListener.h:36
Definition: ContinuousQueryListener.h:34
Flag
Definition: Flag.h:8
TimeUnit
Definition: TimeUnit.h:13
@ SECONDS
Definition: TimeUnit.h:14
@ MINUTES
Definition: TimeUnit.h:18
@ HOURS
Definition: TimeUnit.h:20
@ MICROSECONDS
Definition: TimeUnit.h:17
@ NANOSECONDS
Definition: TimeUnit.h:16
@ DAYS
Definition: TimeUnit.h:19
@ MILLISECONDS
Definition: TimeUnit.h:15
Definition: AuthenticationConfiguration.h:10
Definition: DataFormat.h:86
std::shared_ptr< Marshaller< V > > valueMarshaller
Definition: DataFormat.h:100
std::shared_ptr< Marshaller< K > > keyMarshaller
Definition: DataFormat.h:99