InfinispanHotRodC++Client  8.2.0.Alpha1
 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 
14 #include <cmath>
15 #include <set>
16 #include <map>
17 #include <sstream>
18 #include <stdexcept>
19 #include <vector>
20 #include <functional>
21 #include <future>
22 
23 namespace infinispan {
24 namespace hotrod {
55 template <class K, class V> class RemoteCache : private RemoteCacheBase
56 {
57  private:
58 #ifndef SWIG // Let SWIG ignore this method
59  template<typename Function>
60  inline std::future<typename std::result_of<Function()>::type> goAsync(Function&& f,
61  std::function<typename std::result_of<Function()>::type (typename std::result_of<Function()>::type)> success, std::function<typename std::result_of<Function()>::type (std::exception&)> fail)
62  {
63  auto fq= [=]{ try{ return success==0 ? f() : success(f());}
64  catch (std::exception& ex)
65  {if (fail!=0){return fail(ex);}
66  else {throw ex;}}
67  };
68  return std::async(fq);
69  }
70 #endif
71 
72  public:
78  std::string getName() {
79  return std::string(base_getName());
80  }
81 
87  std::string getVersion() {
89  }
90 
96  std::string getProtocolVersion() {
98  }
99 
107  V* get(const K& key) {
108  return (V *) base_get(&key);
109  }
110 
120  std::future<V*> getAsync(const K& key, std::function<V* (V*)> success=nullptr, std::function<V* (std::exception&)> fail=nullptr) {
121  auto pKey=&key;
122  auto f= [=] { return this->get(*pKey); };
123  return goAsync(f,success,fail);
124  }
125 
146  V* put(const K& key, const V& val, uint64_t lifespan = 0, uint64_t maxIdle = 0) {
147  return put(key, val, lifespan, SECONDS, maxIdle, SECONDS);
148  }
168  V* put(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit) {
169  return put(key, val, lifespan, lifespanUnit, 0, SECONDS);
170  }
171 
194  V* put(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit) {
195  return (V *) base_put(&key, &val, toSeconds(lifespan, lifespanUnit), toSeconds(maxIdle, maxIdleUnit));
196  }
197 
206  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) {
207  auto pKey=&key, pVal=&val;
208  auto f=[=] { return this->put(*pKey,*pVal,lifespan,maxIdle); };
209  return goAsync(f,success,fail);
210  }
211 
220  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) {
221  auto pKey=&key, pVal=&val;
222  auto f= [=] { return this->put(*pKey,*pVal,lifespan,lifespanUnit); };
223  return goAsync(f,success,fail);
224  }
225 
234  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) {
235  auto pKey=&key, pVal=&val;
236  auto f= [=] { this->put(*pKey,*pVal,lifespan, lifespanUnit,maxIdle,maxIdleUnit); };
237  return goAsync(f,success,fail);
238  }
239 
251  V* putIfAbsent(const K& key, const V& val, uint64_t lifespan = 0, uint64_t maxIdle = 0) {
252  return putIfAbsent(key, val, lifespan, SECONDS, maxIdle, SECONDS);
253  }
264  V* putIfAbsent(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit) {
265  return putIfAbsent(key, val, lifespan, lifespanUnit, 0, SECONDS);
266  }
280  V* putIfAbsent(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit) {
281  return (V *)base_putIfAbsent(&key, &val, toSeconds(lifespan, lifespanUnit), toSeconds(maxIdle, maxIdleUnit));
282  }
291  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) {
292  auto pKey=&key, pVal=&val;
293  auto f= [=] { this->putIfAbsent(*pKey,*pVal, lifespan, maxIdle); };
294  return goAsync(f,success,fail);
295  }
304  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) {
305  auto pKey=&key, pVal=&val;
306  auto f= [=] { this->putIfAbsent(*pKey,*pVal, lifespan, lifespanUnit, 0, SECONDS); };
307  return goAsync(f,success,fail);
308  }
317  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) {
318  auto pKey=&key, pVal=&val;
319  auto f= [=] { this->putIfAbsent(*pKey,*pVal, lifespan, lifespanUnit, maxIdle, maxIdleUnit); };
320  return goAsync(f,success,fail);
321  }
322 
323 
334  void putAll(const std::map<K, V>& map, uint64_t lifespan = 0, uint64_t maxIdle = 0) {
335  putAll(map, lifespan, SECONDS, maxIdle, SECONDS);
336  }
337 
348  void putAll(const std::map<K, V>& map, uint64_t lifespan, TimeUnit lifespanUnit) {
349  putAll(map, lifespan, lifespanUnit, 0, SECONDS);
350  }
351 
365  void putAll(const std::map<K, V>& map, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit) {
366  uint64_t lifespanMillis = toSeconds(lifespan, lifespanUnit);
367  uint64_t maxIdleMillis = toSeconds(maxIdle, maxIdleUnit);
368 
369  for (typename std::map<K, V>::const_iterator it = map.begin(); it != map.end(); ++it) {
370  put(it->first, it->second, lifespanMillis, maxIdleMillis);
371  }
372  }
373 
382  std::future<void> putAllAsync(const std::map<K, V>& map, uint64_t lifespan = 0, uint64_t maxIdle = 0, std::function<V* (V*)> success=nullptr, std::function<void (std::exception&)> fail=nullptr) {
383  auto pMap = &pMap;
384  auto f = [=] { this->putAll(*pMap,lifespan, maxIdle); };
385  return goAsync(f,success,fail);
386  }
387 
396  std::future<void> putAllAsync(const std::map<K, V>& map, uint64_t lifespan, TimeUnit lifespanUnit, std::function<V* (V*)> success=nullptr, std::function<void (std::exception&)> fail=nullptr) {
397  auto pMap = &pMap;
398  auto f = [=] { this->putAll(*pMap,lifespan, lifespanUnit); };
399  return goAsync(f,success,fail);
400  }
401 
410  std::future<void> putAllAsync(const std::map<K, V>& map, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit, std::function<V* (V*)> success=nullptr, std::function<void (std::exception&)> fail=nullptr) {
411  auto pMap = &pMap;
412  auto f = [=] { this->putAll(*pMap,lifespan, lifespanUnit, maxIdle, maxIdleUnit); };
413  return goAsync(f,success,fail);
414  }
415 
427  V* replace(const K& key, const V& val, uint64_t lifespan = 0, uint64_t maxIdle = 0) {
428  return replace(key, val, lifespan, SECONDS, maxIdle, SECONDS);
429  }
441  V* replace(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit) {
442  return replace(key, val, lifespan, lifespanUnit, 0, SECONDS);
443  }
457  V* replace(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit) {
458  return (V *) base_replace(&key, &val, toSeconds(lifespan, lifespanUnit), toSeconds(maxIdle, maxIdleUnit));
459  }
472  V* replace(const K& key, const V& oldVal, const V& val, uint64_t lifespan = 0, uint64_t maxIdle = 0) {
473  return replace(key, oldVal, val, lifespan, SECONDS, maxIdle, SECONDS);
474  }
486  V* replace(const K& key, const V& oldVal, const V& val, uint64_t lifespan, TimeUnit lifespanUnit) {
487  return replace(key, oldVal, val, lifespan, lifespanUnit, 0, SECONDS);
488  }
502  V* replace(const K& key, const V& oldVal, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit) {
504  }
505 
514  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<void (std::exception&)> fail=nullptr) {
515  auto pKey=&key, pVal=&val;
516  auto f= [=] { this->replace(*pKey, *pVal, lifespan, SECONDS, maxIdle, SECONDS); };
517  return goAsync(f,success,fail);
518  }
519 
528  std::future<V*> replaceAsync(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, std::function<V* (V*)> success=nullptr, std::function<void (std::exception&)> fail=nullptr) {
529  auto pKey=&key, pVal=&val;
530  auto f= [=] { this->replace(*pKey, *pVal, lifespan, lifespanUnit, 0, SECONDS); };
531  return goAsync(f,success,fail);
532  }
533 
542  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<void (std::exception&)> fail=nullptr) {
543  auto pKey=&key, pVal=&val;
544  auto f= [=] { this->replace(*pKey, *pVal, lifespan, lifespanUnit, maxIdle, maxIdleUnit); };
545  return goAsync(f,success,fail);
546  }
547 
556  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<void (std::exception&)> fail=nullptr) {
557  auto pKey=&key, pVal=&val, pOldVal=&oldVal;
558  auto f= [=] { this->replace(*pKey, *oldVal, *pVal, lifespan, SECONDS, maxIdle, SECONDS); };
559  return goAsync(f,success,fail);
560  }
561 
570  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<void (std::exception&)> fail=nullptr) {
571  auto pKey=&key, pVal=&val, pOldVal=&oldVal;
572  auto f= [=] { this->replace(*pKey, *oldVal, *pVal, lifespan, lifespanUnit, 0, SECONDS); };
573  return goAsync(f,success,fail);
574  }
575 
576 
583  V* remove(const K& key) {
584  return (V *) base_remove(&key);
585  }
586 
595  std::future<bool> removeAsync(const K& key, std::function<V* (V*)> success=nullptr, std::function<void (std::exception&)> fail=nullptr) {
596  auto f = [=] { this->remove(&key); };
597  return goAsync(f,success,fail);
598  }
599 
600 
606  bool containsKey(const K& key) {
607  return base_containsKey(&key);
608  }
609 
614  bool containsValue(const V& val) {
616  }
632  const K& key, const V& val,
633  uint64_t version, uint64_t lifespan = 0, uint64_t maxIdle = 0) {
634  return base_replaceWithVersion(&key, &val, version, lifespan, maxIdle);
635  }
636 
645  std::future<void> replaceWithVersionAsync(const K& key, const V& val,
646  uint64_t version, uint64_t lifespan, uint64_t maxIdle, std::function<V* (V*)> success=nullptr, std::function<void (std::exception&)> fail=nullptr) {
647  auto f = [=] { this->replaceWithVersion(&key, &val, version, lifespan, maxIdle); };
648  return goAsync(f,success,fail);
649  }
650 
669  bool removeWithVersion(const K& key, uint64_t version) {
670  return base_removeWithVersion(&key, version);
671  }
672 
681  std::future<bool> removeWithVersionAsync(const K& key, uint64_t version, std::function<V* (V*)> success=nullptr, std::function<void (std::exception&)> fail=nullptr) {
682  auto f = [=] { this->removeWithVersion(&key, version); };
683  return goAsync(f,success,fail);
684  }
685 
696  std::pair<std::shared_ptr<V>, VersionedValue> getWithVersion(const K& key) {
697  VersionedValue version;
698  void *value = base_getWithVersion(&key, &version);
699  return std::make_pair(std::shared_ptr<V>((V *) value), version);
700  }
711  std::pair<std::shared_ptr<V>, MetadataValue> getWithMetadata(const K& key) {
712  MetadataValue metadata;
713  void *value = base_getWithMetadata(&key, &metadata);
714  return std::make_pair(std::shared_ptr<V>((V *) value), metadata);
715  }
720  std::map<std::shared_ptr<K>, std::shared_ptr<V> > getBulk() {
721  return getBulk(0);
722  }
727  std::map<std::shared_ptr<K>, std::shared_ptr<V> > getBulk(int nrOfEntries) {
728  std::map<void* , void*> mbuf;
729  std::map<std::shared_ptr<K>, std::shared_ptr<V> > result;
730  base_getBulk(nrOfEntries, mbuf);
731  for (auto it = mbuf.begin(); it != mbuf.end(); ++it)
732  {
733  result[std::shared_ptr<K>((K*)it->first)]=std::shared_ptr<V>((V*)it->second);
734  }
735  return result;
736  }
743  std::vector<unsigned char> execute(const std::string& name, const std::map<std::string,std::string>& args)
744  {
745  return base_execute(name,args);
746  }
747 
754  QueryResponse query(const QueryRequest &qr)
755  {
756  return base_query(qr);
757  }
758 
765  std::vector<unsigned char> query(std::vector<unsigned char> qr, size_t size)
766  {
767  return base_query_char(qr,size);
768  }
769 
774  std::set<std::pair<K, V> > entrySet() {
776  }
784  std::set<std::shared_ptr<K> > keySet() {
785  std::vector<void*> p;
786  base_keySet(0, p);
787 
788  std::set<std::shared_ptr<K> > result;
789  for (size_t i = 0; i < p.size(); ++i) {
790  result.insert(std::shared_ptr<K>((K*)p.data()[i]));
791  }
792  return result;
793  }
799  uint64_t size() {
800  return base_size();
801  }
807  bool isEmpty() {
808  return 0 == size();
809  }
814  std::vector<V> values() {
816  }
823  std::map<std::string, std::string> stats() {
824  std::map<std::string, std::string> statistics;
825  base_stats(statistics);
826  return statistics;
827  }
833  void clear() {
834  base_clear();
835  }
836 
837 
846  std::future<void> clearAsync(std::function<V* (V*)> success=nullptr, std::function<void (std::exception&)> fail=nullptr) {
847  auto f = [=] { this->clear(); };
848  return goAsync(f,success,fail);
849  }
850 
856  void ping() {
857  base_ping();
858  }
859 
860  void addClientListener(ClientListener& clientListener, std::vector<std::vector<char> > filterFactoryParams, std::vector<std::vector<char> > converterFactoryParams, const std::function<void()> &recoveryCallback = nullptr)
861  {
862  base_addClientListener(clientListener, filterFactoryParams, converterFactoryParams, recoveryCallback);
863  }
864 
865  void removeClientListener(ClientListener& clientListener)
866  {
867  base_removeClientListener(clientListener);
868  }
869 
871  return base_getCacheTopologyInfo();
872  }
880  base_withFlags(flags);
881  return *this;
882  }
883 
884  RemoteCache(const RemoteCache &other) :
885  RemoteCacheBase(other), keyMarshaller(other.keyMarshaller), valueMarshaller(other.valueMarshaller)
886  {
887  setMarshallers(this, &keyMarshall, &valueMarshall, &keyUnmarshall, &valueUnmarshall);
888  }
889 
891  RemoteCacheBase::operator=(other);
892  keyMarshaller = other.keyMarshaller;
893  valueMarshaller = other.valueMarshaller;
894  setMarshallers(this, &keyMarshall, &valueMarshall, &keyUnmarshall, &valueUnmarshall);
895  return *this;
896  }
897 
898  protected:
900  setMarshallers(this, &keyMarshall, &valueMarshall, &keyUnmarshall, &valueUnmarshall);
901  }
902 
903  private:
904  uint64_t toSeconds(uint64_t time, TimeUnit unit) {
905  uint64_t result;
906  switch (unit) {
907  case NANOSECONDS:
908  result = (uint64_t) ceil(time / 1000000000.0);
909  break;
910  case MICROSECONDS:
911  result = (uint64_t) ceil(time / 1000000.0);
912  break;
913  case MILLISECONDS:
914  result = (uint64_t) ceil(time / 1000.0);
915  break;
916  case SECONDS:
917  result = time;
918  break;
919  case MINUTES:
920  result = time * 60;
921  break;
922  case HOURS:
923  result = time * 3600;
924  break;
925  case DAYS:
926  result = time * 86400;
927  break;
928  default:
929  std::stringstream ss;
930  ss << "Unhandled TimeUnit specified: " << unit << ".";
931  throw std::invalid_argument(ss.str());
932  }
933  return result;
934  }
935 
936  // type-hiding and resurrecting support
937  static void keyMarshall(void *thisp, const void* key, std::vector<char> &buf) {
938  ((RemoteCache<K, V> *) thisp)->keyMarshaller->marshall(*(const K *) key, buf);
939  }
940  static void valueMarshall(void* thisp, const void* val, std::vector<char> &buf) {
941  ((RemoteCache<K, V> *)thisp)->valueMarshaller->marshall(*(const V *) val, buf);
942  }
943  static void* keyUnmarshall(void *thisp, const std::vector<char> &buf) {
944  return ((RemoteCache<K, V> *) thisp)->keyMarshaller->unmarshall(buf);
945  }
946  static void* valueUnmarshall(void* thisp, const std::vector<char> &buf) {
947  return ((RemoteCache<K, V> *)thisp)->valueMarshaller->unmarshall(buf);
948  }
949 
950  std::shared_ptr<Marshaller<K> > keyMarshaller;
951  std::shared_ptr<Marshaller<V> > valueMarshaller;
952 
953  friend class RemoteCacheManager;
954 };
955 
956 }} // namespace
957 
958 #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:365
HR_EXTERN QueryResponse base_query(const QueryRequest &qr)
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:220
std::map< std::shared_ptr< K >, std::shared_ptr< V > > getBulk(int nrOfEntries)
Definition: RemoteCache.h:727
V * putIfAbsent(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit)
Definition: RemoteCache.h:264
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:291
std::vector< unsigned char > query(std::vector< unsigned char > qr, size_t size)
Definition: RemoteCache.h:765
HR_EXTERN void base_removeClientListener(ClientListener &clientListener)
HR_EXTERN void * base_replace(const void *key, const void *value, int64_t life, int64_t idle)
V * put(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit)
Definition: RemoteCache.h:194
std::string getName()
Definition: RemoteCache.h:78
std::pair< std::shared_ptr< V >, VersionedValue > getWithVersion(const K &key)
Definition: RemoteCache.h:696
std::set< std::pair< K, V > > entrySet()
Definition: RemoteCache.h:774
HR_EXTERN bool base_replaceWithVersion(const void *key, const void *value, int64_t version, int64_t life, int64_t idle)
HR_EXTERN bool base_containsKey(const void *key)
HR_EXTERN void base_withFlags(Flag flag)
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< void(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:570
HR_EXTERN void setMarshallers(void *rc, MarshallHelperFn kf, MarshallHelperFn vf, UnmarshallHelperFn ukf, UnmarshallHelperFn uvf)
static const char * getProtocolVersionCString()
Definition: Version.h:32
Definition: CacheTopologyInfo.h:10
bool containsKey(const K &key)
Definition: RemoteCache.h:606
HR_EXTERN void * base_remove(const void *key)
std::map< std::string, std::string > stats()
Definition: RemoteCache.h:823
HR_EXTERN void * base_put(const void *key, const void *value, int64_t life, int64_t idle)
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:317
std::future< bool > removeAsync(const K &key, std::function< V *(V *)> success=nullptr, std::function< void(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:595
V * replace(const K &key, const V &oldVal, const V &val, uint64_t lifespan=0, uint64_t maxIdle=0)
Definition: RemoteCache.h:472
std::set< std::shared_ptr< K > > keySet()
Definition: RemoteCache.h:784
void putAll(const std::map< K, V > &map, uint64_t lifespan=0, uint64_t maxIdle=0)
Definition: RemoteCache.h:334
RemoteCache< K, V > & withFlags(Flag flags)
Definition: RemoteCache.h:879
std::vector< V > values()
Definition: RemoteCache.h:814
HR_EXTERN bool base_removeWithVersion(const void *key, int64_t version)
V * putIfAbsent(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit)
Definition: RemoteCache.h:280
std::map< std::shared_ptr< K >, std::shared_ptr< V > > getBulk()
Definition: RemoteCache.h:720
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< void(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:556
RemoteCache< K, V > & operator=(const RemoteCache &other)
Definition: RemoteCache.h:890
std::future< bool > removeWithVersionAsync(const K &key, uint64_t version, std::function< V *(V *)> success=nullptr, std::function< void(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:681
HR_EXTERN const char * base_getName()
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:251
Definition: TimeUnit.h:15
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< void(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:542
std::future< void > putAllAsync(const std::map< K, V > &map, uint64_t lifespan, TimeUnit lifespanUnit, std::function< V *(V *)> success=nullptr, std::function< void(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:396
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:206
V * replace(const K &key, const V &oldVal, const V &val, uint64_t lifespan, TimeUnit lifespanUnit)
Definition: RemoteCache.h:486
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:304
uint64_t size()
Definition: RemoteCache.h:799
std::future< V * > getAsync(const K &key, std::function< V *(V *)> success=nullptr, std::function< V *(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:120
void removeClientListener(ClientListener &clientListener)
Definition: RemoteCache.h:865
RemoteCache()
Definition: RemoteCache.h:899
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:860
std::vector< unsigned char > execute(const std::string &name, const std::map< std::string, std::string > &args)
Definition: RemoteCache.h:743
std::future< void > putAllAsync(const std::map< K, V > &map, uint64_t lifespan=0, uint64_t maxIdle=0, std::function< V *(V *)> success=nullptr, std::function< void(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:382
CacheTopologyInfo getCacheTopologyInfo()
Definition: RemoteCache.h:870
void clear()
Definition: RemoteCache.h:833
bool isEmpty()
Definition: RemoteCache.h:807
V * put(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit)
Definition: RemoteCache.h:168
RemoteCache(const RemoteCache &other)
Definition: RemoteCache.h:884
HR_EXTERN std::vector< unsigned char > base_execute(const std::string &cmdName, const std::map< std::string, std::string > &args)
HR_EXTERN void * base_putIfAbsent(const void *key, const void *value, int64_t life, int64_t idle)
bool replaceWithVersion(const K &key, const V &val, uint64_t version, uint64_t lifespan=0, uint64_t maxIdle=0)
Definition: RemoteCache.h:631
std::string getVersion()
Definition: RemoteCache.h:87
Definition: RemoteCacheManager.h:38
Definition: TimeUnit.h:17
std::string getProtocolVersion()
Definition: RemoteCache.h:96
HR_EXTERN void * base_getWithVersion(const void *key, VersionedValue *version)
V * replace(const K &key, const V &oldVal, const V &val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit)
Definition: RemoteCache.h:502
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:457
void ping()
Definition: RemoteCache.h:856
HR_EXTERN void base_keySet(int scope, std::vector< void * > &sbuf)
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:234
HR_EXTERN CacheTopologyInfo base_getCacheTopologyInfo()
QueryResponse query(const QueryRequest &qr)
Definition: RemoteCache.h:754
HR_EXTERN void base_stats(std::map< std::string, std::string > &sbuf)
HR_EXTERN void base_addClientListener(ClientListener &clientListener, const std::vector< std::vector< char > > filterFactoryParam, const std::vector< std::vector< char > > converterFactoryParams, const std::function< void()> &recoveryCallback)
HR_EXTERN void * base_getWithMetadata(const void *key, MetadataValue *metadata)
static const char * getVersionCString()
Definition: Version.h:41
TimeUnit
Definition: TimeUnit.h:13
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< void(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:514
Definition: RemoteCacheBase.h:36
HR_EXTERN std::vector< unsigned char > base_query_char(std::vector< unsigned char > qr, size_t size)
std::future< void > putAllAsync(const std::map< K, V > &map, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit, std::function< V *(V *)> success=nullptr, std::function< void(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:410
HR_EXTERN void base_getBulk(int size, std::map< void *, void * > &mbuf)
std::future< V * > replaceAsync(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit, std::function< V *(V *)> success=nullptr, std::function< void(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:528
bool containsValue(const V &val)
Definition: RemoteCache.h:614
V * replace(const K &key, const V &val, uint64_t lifespan, TimeUnit lifespanUnit)
Definition: RemoteCache.h:441
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:427
std::pair< std::shared_ptr< V >, MetadataValue > getWithMetadata(const K &key)
Definition: RemoteCache.h:711
Flag
Definition: Flag.h:7
std::future< void > clearAsync(std::function< V *(V *)> success=nullptr, std::function< void(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:846
std::future< void > replaceWithVersionAsync(const K &key, const V &val, uint64_t version, uint64_t lifespan, uint64_t maxIdle, std::function< V *(V *)> success=nullptr, std::function< void(std::exception &)> fail=nullptr)
Definition: RemoteCache.h:645
Definition: VersionedValue.h:9
V * put(const K &key, const V &val, uint64_t lifespan=0, uint64_t maxIdle=0)
Definition: RemoteCache.h:146
HR_EXTERN void * base_get(const void *key)
void putAll(const std::map< K, V > &map, uint64_t lifespan, TimeUnit lifespanUnit)
Definition: RemoteCache.h:348
bool removeWithVersion(const K &key, uint64_t version)
Definition: RemoteCache.h:669