 |
Apache Ignite C++
|
Go to the documentation of this file.
23 #ifndef _IGNITE_THIN_CACHE_CACHE_CLIENT
24 #define _IGNITE_THIN_CACHE_CACHE_CLIENT
26 #include <ignite/common/concurrent.h>
33 #include <ignite/impl/thin/writable.h>
34 #include <ignite/impl/thin/writable_key.h>
36 #include <ignite/impl/thin/readable.h>
37 #include <ignite/impl/thin/cache/cache_client_proxy.h>
38 #include <ignite/impl/thin/cache/continuous/continuous_query_client_holder.h>
61 template<
typename K,
typename V>
64 friend class impl::thin::cache::CacheClientProxy;
78 explicit CacheClient(
const common::concurrent::SharedPointer<void>& impl) :
108 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
109 impl::thin::WritableImpl<ValueType> wrValue(value);
111 proxy.Put(wrKey, wrValue);
121 template<
typename InIter>
124 impl::thin::WritableMapImpl<K, V, InIter> wrSeq(begin, end);
135 template<
typename Map>
138 PutAll(vals.begin(), vals.end());
149 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
150 impl::thin::ReadableImpl<ValueType> rdValue(value);
152 proxy.Get(wrKey, rdValue);
180 template<
typename InIter,
typename OutIter>
181 void GetAll(InIter begin, InIter end, OutIter dst)
183 impl::thin::WritableSetImpl<K, InIter> wrSeq(begin, end);
184 impl::thin::ReadableMapImpl<K, V, OutIter> rdSeq(dst);
186 proxy.GetAll(wrSeq, rdSeq);
198 template<
typename Set,
typename Map>
201 return GetAll(keys.begin(), keys.end(), std::inserter(res, res.end()));
218 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
219 impl::thin::WritableImpl<ValueType> wrValue(value);
221 return proxy.Replace(wrKey, wrValue);
235 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
236 impl::thin::WritableImpl<ValueType> wrOldVal(oldVal);
237 impl::thin::WritableImpl<ValueType> wrNewVal(newVal);
239 return proxy.Replace(wrKey, wrOldVal, wrNewVal);
250 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
252 return proxy.ContainsKey(wrKey);
261 template<
typename Set>
274 template<
typename InIter>
277 impl::thin::WritableSetImpl<K, InIter> wrSeq(begin, end);
279 return proxy.ContainsKeys(wrSeq);
293 return proxy.GetSize(peekModes);
310 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
312 return proxy.Remove(wrKey);
325 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
326 impl::thin::WritableImpl<ValueType> wrVal(val);
328 return proxy.Remove(wrKey, wrVal);
337 template<
typename Set>
350 template<
typename InIter>
353 impl::thin::WritableSetImpl<K, InIter> wrSeq(begin, end);
355 proxy.RemoveAll(wrSeq);
376 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
395 template<
typename Set>
408 template<
typename InIter>
411 impl::thin::WritableSetImpl<K, InIter> wrSeq(begin, end);
413 proxy.ClearAll(wrSeq);
427 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
428 impl::thin::WritableImpl<ValueType> wrValIn(valIn);
429 impl::thin::ReadableImpl<ValueType> rdValOut(valOut);
431 proxy.GetAndPut(wrKey, wrValIn, rdValOut);
461 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
462 impl::thin::ReadableImpl<ValueType> rdValOut(valOut);
464 proxy.GetAndRemove(wrKey, rdValOut);
494 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
495 impl::thin::WritableImpl<ValueType> wrValIn(valIn);
496 impl::thin::ReadableImpl<ValueType> rdValOut(valOut);
498 proxy.GetAndReplace(wrKey, wrValIn, rdValOut);
529 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
530 impl::thin::WritableImpl<ValueType> wrValIn(val);
532 return proxy.PutIfAbsent(wrKey, wrValIn);
556 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
557 impl::thin::WritableImpl<ValueType> wrValIn(valIn);
558 impl::thin::ReadableImpl<ValueType> rdValOut(valOut);
560 proxy.GetAndPutIfAbsent(wrKey, wrValIn, rdValOut);
599 return proxy.Query(qry);
611 using namespace impl::thin::cache::query::continuous;
613 SP_ContinuousQueryClientHolderBase holder(
new ContinuousQueryClientHolder<K, V>(continuousQuery));
615 return proxy.QueryContinuous(holder);
636 impl::thin::cache::CacheClientProxy proxy;
642 #endif // _IGNITE_THIN_CACHE_CACHE_CLIENT
void PutAll(InIter begin, InIter end)
Stores given key-value pairs in cache.
Definition: cache_client.h:122
Apache Ignite API.
Definition: cache.h:48
void RemoveAll()
Removes all mappings from cache.
Definition: cache_client.h:363
ValueType GetAndRemove(const KeyType &key)
Atomically removes the entry for a key only if currently mapped to some value.
Definition: cache_client.h:474
~CacheClient()
Destructor.
Definition: cache_client.h:95
bool Remove(const KeyType &key)
Removes given key mapping from cache.
Definition: cache_client.h:308
Continuous query client.
Definition: continuous_query_client.h:53
void RemoveAll(InIter begin, InIter end)
Removes given key mappings from cache.
Definition: cache_client.h:351
ValueType GetAndReplace(const KeyType &key, const ValueType &valIn)
Atomically replaces the value for a given key if and only if there is a value currently mapped by the...
Definition: cache_client.h:510
Query fields cursor.
Definition: thin-client/include/ignite/thin/cache/query/query_fields_cursor.h:48
bool ContainsKeys(const Set &keys)
Check if cache contains mapping for these keys.
Definition: cache_client.h:262
int64_t GetSize(int32_t peekModes)
Gets the number of all entries cached across all nodes.
Definition: cache_client.h:291
Continuous query handle client.
Definition: thin-client/include/ignite/thin/cache/query/continuous/continuous_query_handle.h:43
SQL fields query for thin client.
Definition: thin-client/include/ignite/thin/cache/query/query_sql_fields.h:52
CacheClient(const common::concurrent::SharedPointer< void > &impl)
Constructor.
Definition: cache_client.h:78
ValueType GetAndPutIfAbsent(const KeyType &key, const ValueType &valIn)
Stores given key-value pair in cache only if cache had no previous mapping for it.
Definition: cache_client.h:582
void RemoveAll(const Set &keys)
Removes given key mappings from cache.
Definition: cache_client.h:338
bool ContainsKey(const KeyType &key)
Check if the cache contains a value for the specified key.
Definition: cache_client.h:248
query::continuous::ContinuousQueryHandleClient QueryContinuous(query::continuous::ContinuousQueryClient< K, V > continuousQuery)
Starts the continuous query execution.
Definition: cache_client.h:608
ValueType GetAndPut(const KeyType &key, const ValueType &valIn)
Associates the specified value with the specified key in this cache, returning an existing value if o...
Definition: cache_client.h:443
K KeyType
Key type.
Definition: cache_client.h:68
Cache client class template.
Definition: cache_client.h:62
query::QueryFieldsCursor Query(const query::SqlFieldsQuery &qry)
Perform SQL fields query.
Definition: cache_client.h:597
V ValueType
Value type.
Definition: cache_client.h:71
bool Replace(const KeyType &key, const ValueType &oldVal, const ValueType &newVal)
Stores given key-value pair in cache only if the previous value is equal to the old value passed as a...
Definition: cache_client.h:233
bool PutIfAbsent(const KeyType &key, const ValueType &val)
Atomically associates the specified key with the given value if it is not already associated with a v...
Definition: cache_client.h:527
void Get(const KeyType &key, ValueType &value)
Get value from the cache.
Definition: cache_client.h:147
CacheClient()
Default constructor.
Definition: cache_client.h:87
void GetAndPut(const KeyType &key, const ValueType &valIn, ValueType &valOut)
Associates the specified value with the specified key in this cache, returning an existing value if o...
Definition: cache_client.h:425
void ClearAll(InIter begin, InIter end)
Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
Definition: cache_client.h:409
void Put(const KeyType &key, const ValueType &value)
Associate the specified value with the specified key in the cache.
Definition: cache_client.h:106
void GetAll(InIter begin, InIter end, OutIter dst)
Retrieves values mapped to the specified keys from cache.
Definition: cache_client.h:181
void GetAll(const Set &keys, Map &res)
Retrieves values mapped to the specified keys from cache.
Definition: cache_client.h:199
bool Replace(const K &key, const V &value)
Stores given key-value pair in cache only if there is a previous mapping for it.
Definition: cache_client.h:216
void Clear(const KeyType &key)
Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
Definition: cache_client.h:374
void PutAll(const Map &vals)
Stores given key-value pairs in cache.
Definition: cache_client.h:136
void GetAndRemove(const KeyType &key, ValueType &valOut)
Atomically removes the entry for a key only if currently mapped to some value.
Definition: cache_client.h:459
void Clear()
Clear cache.
Definition: cache_client.h:384
void GetAndReplace(const KeyType &key, const ValueType &valIn, ValueType &valOut)
Atomically replaces the value for a given key if and only if there is a value currently mapped by the...
Definition: cache_client.h:492
void GetAndPutIfAbsent(const KeyType &key, const ValueType &valIn, ValueType &valOut)
Stores given key-value pair in cache only if cache had no previous mapping for it.
Definition: cache_client.h:554
void RefreshAffinityMapping()
Refresh affinity mapping.
Definition: cache_client.h:629
bool ContainsKeys(InIter begin, InIter end)
Check if cache contains mapping for these keys.
Definition: cache_client.h:275
bool Remove(const KeyType &key, const ValueType &val)
Removes given key mapping from cache if one exists and value is equal to the passed in value.
Definition: cache_client.h:323
void ClearAll(const Set &keys)
Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
Definition: cache_client.h:396
ValueType Get(const KeyType &key)
Get value from cache.
Definition: cache_client.h:161