diff --git a/include/infinispan/hotrod/RemoteCache.h b/include/infinispan/hotrod/RemoteCache.h index bd7cfa99..69048155 100644 --- a/include/infinispan/hotrod/RemoteCache.h +++ b/include/infinispan/hotrod/RemoteCache.h @@ -283,6 +283,47 @@ template class RemoteCache : private RemoteCacheBase V* putIfAbsent(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit) { return (V *)base_putIfAbsent(&key, &val, toSeconds(lifespan, lifespanUnit), toSeconds(maxIdle, maxIdleUnit)); } + /** + * Asynchronous version of putIfAbsentAsync() + * See the synchronous doc for parameters not explained here + * \param success function to be executed on success + * \param fail function to be executed if exceptions occur + * \return a future containing a pointer to the previous value stored in the cache for the given key or null + * + */ + std::future putIfAbsentAsync(const K& key, const V& val, uint64_t lifespan = 0, uint64_t maxIdle = 0, std::function success=nullptr, std::function fail=nullptr) { + auto pKey=&key, pVal=&val; + auto f= [=] { this->putIfAbsent(*pKey,*pVal, lifespan, maxIdle); }; + return goAsync(f,success,fail); + } + /** + * Asynchronous version of putIfAbsentAsync() + * See the synchronous doc for parameters not explained here + * \param success function to be executed on success + * \param fail function to be executed if exceptions occur + * \return a future containing a pointer to the previous value stored in the cache for the given key or null + * + */ + std::future putIfAbsentAsync(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, std::function success=nullptr, std::function fail=nullptr) { + auto pKey=&key, pVal=&val; + auto f= [=] { this->putIfAbsent(*pKey,*pVal, lifespan, lifespanUnit, 0, SECONDS); }; + return goAsync(f,success,fail); + } + /** + * Asynchronous version of putIfAbsentAsync() + * See the synchronous doc for parameters not explained here + * \param success function to be executed on success + * \param fail function to be executed if exceptions occur + * \return a future containing a pointer to the previous value stored in the cache for the given key or null + * + */ + std::future putIfAbsentAsync(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit, std::function success=nullptr, std::function fail=nullptr) { + auto pKey=&key, pVal=&val; + auto f= [=] { this->putIfAbsent(*pKey,*pVal, lifespan, lifespanUnit, maxIdle, maxIdleUnit); }; + return goAsync(f,success,fail); + } + + /** * Copies all of the mappings from the specified map to this cache. The effect of this call is equivalent to that of * calling put(k, v) on this cache once for each mapping from key k to value v in the specified map. @@ -465,6 +506,77 @@ template class RemoteCache : private RemoteCacheBase throw UnsupportedOperationException(); } + /** + * Asynchronous version of replace() + * See the synchronous doc for parameters not explained here + * \param success function to be executed on success + * \param fail function to be executed if exceptions occur + * \return a future containing a pointer to the previous value stored in the cache for the given key or null + * + */ + std::future replaceAsync(const K& key, const V& val, uint64_t lifespan = 0, uint64_t maxIdle = 0, std::function success=nullptr, std::function fail=nullptr) { + auto pKey=&key, pVal=&val; + auto f= [=] { this->replace(*pKey, *pVal, lifespan, SECONDS, maxIdle, SECONDS); }; + return goAsync(f,success,fail); + } + + /** + * Asynchronous version of replace() + * See the synchronous doc for parameters not explained here + * \param success function to be executed on success + * \param fail function to be executed if exceptions occur + * \return a future containing a pointer to the previous value stored in the cache for the given key or null + * + */ + std::future replaceAsync(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, std::function success=nullptr, std::function fail=nullptr) { + auto pKey=&key, pVal=&val; + auto f= [=] { this->replace(*pKey, *pVal, lifespan, lifespanUnit, 0, SECONDS); }; + return goAsync(f,success,fail); + } + + /** + * Asynchronous version of replace() + * See the synchronous doc for parameters not explained here + * \param success function to be executed on success + * \param fail function to be executed if exceptions occur + * \return a future containing a pointer to the previous value stored in the cache for the given key or null + * + */ + std::future replaceAsync(const K& key, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, uint64_t maxIdle, TimeUnit maxIdleUnit, std::function success=nullptr, std::function fail=nullptr) { + auto pKey=&key, pVal=&val; + auto f= [=] { this->replace(*pKey, *pVal, lifespan, lifespanUnit, maxIdle, maxIdleUnit); }; + return goAsync(f,success,fail); + } + + /** + * Asynchronous version of replace() + * See the synchronous doc for parameters not explained here + * \param success function to be executed on success + * \param fail function to be executed if exceptions occur + * \return a future containing a pointer to the previous value stored in the cache for the given key or null + * + */ + std::future replaceAsync(const K& key, const V& oldVal, const V& val, uint64_t lifespan = 0, uint64_t maxIdle = 0, std::function success=nullptr, std::function fail=nullptr) { + auto pKey=&key, pVal=&val, pOldVal=&oldVal; + auto f= [=] { this->replace(*pKey, *oldVal, *pVal, lifespan, SECONDS, maxIdle, SECONDS); }; + return goAsync(f,success,fail); + } + + /** + * Asynchronous version of replace() + * See the synchronous doc for parameters not explained here + * \param success function to be executed on success + * \param fail function to be executed if exceptions occur + * \return a future containing a pointer to the previous value stored in the cache for the given key or null + * + */ + std::future replaceAsync(const K& key, const V& oldVal, const V& val, uint64_t lifespan, TimeUnit lifespanUnit, std::function success=nullptr, std::function fail=nullptr) { + auto pKey=&key, pVal=&val, pOldVal=&oldVal; + auto f= [=] { this->replace(*pKey, *oldVal, *pVal, lifespan, lifespanUnit, 0, SECONDS); }; + return goAsync(f,success,fail); + } + + /** * Removes key/value pair from the cache given a key. Optionally return a value stored * under the given key @@ -475,6 +587,20 @@ template class RemoteCache : private RemoteCacheBase return (V *) base_remove(&key); } + /** + * Asynchronous version of removeWithVersion() + * See the synchronous doc for parameters not explained here + * \param success function to be executed on success + * \param fail function to be executed if exceptions occur + * \return a future containing a bool. True if the entry has been removed + * + */ + std::future removeAsync(const K& key, std::function success=nullptr, std::function fail=nullptr) { + auto f = [=] { this->remove(&key); }; + return goAsync(f,success,fail); + } + + /** * Returns true if this cache contains a key/value pair where the key is equal to a specified key. * @@ -521,7 +647,6 @@ template class RemoteCache : private RemoteCacheBase */ std::future replaceWithVersionAsync(const K& key, const V& val, uint64_t version, uint64_t lifespan, uint64_t maxIdle, std::function success=nullptr, std::function fail=nullptr) { - auto pMap = &pMap; auto f = [=] { this->replaceWithVersion(&key, &val, version, lifespan, maxIdle); }; return goAsync(f,success,fail); } @@ -547,6 +672,20 @@ template class RemoteCache : private RemoteCacheBase bool removeWithVersion(const K& key, uint64_t version) { return base_removeWithVersion(&key, version); } + + /** + * Asynchronous version of removeWithVersion() + * See the synchronous doc for parameters not explained here + * \param success function to be executed on success + * \param fail function to be executed if exceptions occur + * \return a future containing a bool. True if the entry has been removed + * + */ + std::future removeWithVersionAsync(const K& key, uint64_t version, std::function success=nullptr, std::function fail=nullptr) { + auto f = [=] { this->removeWithVersion(&key, version); }; + return goAsync(f,success,fail); + } + /** * Returns the std::pair with value and VersionedValue associated with * the supplied key parameter or a default initialized std::pair if it @@ -700,6 +839,21 @@ template class RemoteCache : private RemoteCacheBase void clear() { base_clear(); } + + + /** + * Asynchronous version of clear() + * See the synchronous doc for parameters not explained here + * \param success function to be executed on success + * \param fail function to be executed if exceptions occur + * \return a future containing a bool. True if the entry has been removed + * + */ + std::future clearAsync(std::function success=nullptr, std::function fail=nullptr) { + auto f = [=] { this->clear(); }; + return goAsync(f,success,fail); + } + /** * Pings remote cache on a Hot Rod server * diff --git a/jni/src/main/swig/java.i b/jni/src/main/swig/java.i index 539b2aa8..f9b50b2d 100644 --- a/jni/src/main/swig/java.i +++ b/jni/src/main/swig/java.i @@ -144,6 +144,11 @@ using namespace infinispan::hotrod; %ignore goAsync; %ignore putAllAsync; %ignore replaceWithVersionAsync; +%ignore removeWithVersionAsync; +%ignore putIfAbsentAsync; +%ignore clearAsync; +%ignore removeAsync; +%ignore replaceAsync; //%shared_ptr(RelayShrPointer)