 |
GridGain C++
|
Go to the documentation of this file.
22 #ifndef _IGNITE_THIN_CACHE_CACHE_CLIENT
23 #define _IGNITE_THIN_CACHE_CACHE_CLIENT
25 #include <ignite/common/concurrent.h>
34 #include <ignite/impl/thin/writable.h>
35 #include <ignite/impl/thin/writable_key.h>
37 #include <ignite/impl/thin/readable.h>
38 #include <ignite/impl/thin/cache/cache_client_proxy.h>
39 #include <ignite/impl/thin/cache/continuous/continuous_query_client_holder.h>
62 template<
typename K,
typename V>
65 friend class impl::thin::cache::CacheClientProxy;
79 explicit CacheClient(
const common::concurrent::SharedPointer<void>& impl) :
109 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
110 impl::thin::WritableImpl<ValueType> wrValue(value);
112 proxy.Put(wrKey, wrValue);
122 template<
typename InIter>
125 impl::thin::WritableMapImpl<K, V, InIter> wrSeq(begin, end);
136 template<
typename Map>
139 PutAll(vals.begin(), vals.end());
151 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
154 proxy.Get(wrKey, rdValue);
156 return !rdValue.IsNull();
184 template<
typename InIter,
typename OutIter>
185 void GetAll(InIter begin, InIter end, OutIter dst)
187 impl::thin::WritableSetImpl<K, InIter> wrSeq(begin, end);
188 impl::thin::ReadableContainerImpl< std::pair<K, V>, OutIter> rdSeq(dst);
190 proxy.GetAll(wrSeq, rdSeq);
202 template<
typename Set,
typename Map>
205 return GetAll(keys.begin(), keys.end(), std::inserter(res, res.end()));
222 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
223 impl::thin::WritableImpl<ValueType> wrValue(value);
225 return proxy.Replace(wrKey, wrValue);
239 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
240 impl::thin::WritableImpl<ValueType> wrOldVal(oldVal);
241 impl::thin::WritableImpl<ValueType> wrNewVal(newVal);
243 return proxy.Replace(wrKey, wrOldVal, wrNewVal);
254 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
256 return proxy.ContainsKey(wrKey);
265 template<
typename Set>
278 template<
typename InIter>
281 impl::thin::WritableSetImpl<K, InIter> wrSeq(begin, end);
283 return proxy.ContainsKeys(wrSeq);
297 return proxy.GetSize(peekModes);
314 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
316 return proxy.Remove(wrKey);
329 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
330 impl::thin::WritableImpl<ValueType> wrVal(val);
332 return proxy.Remove(wrKey, wrVal);
341 template<
typename Set>
354 template<
typename InIter>
357 impl::thin::WritableSetImpl<K, InIter> wrSeq(begin, end);
359 proxy.RemoveAll(wrSeq);
380 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
399 template<
typename Set>
412 template<
typename InIter>
415 impl::thin::WritableSetImpl<K, InIter> wrSeq(begin, end);
417 proxy.ClearAll(wrSeq);
431 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
432 impl::thin::WritableImpl<ValueType> wrValIn(valIn);
435 proxy.GetAndPut(wrKey, wrValIn, rdValOut);
465 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
468 proxy.GetAndRemove(wrKey, rdValOut);
498 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
499 impl::thin::WritableImpl<ValueType> wrValIn(valIn);
502 proxy.GetAndReplace(wrKey, wrValIn, rdValOut);
533 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
534 impl::thin::WritableImpl<ValueType> wrValIn(val);
536 return proxy.PutIfAbsent(wrKey, wrValIn);
560 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
561 impl::thin::WritableImpl<ValueType> wrValIn(valIn);
564 proxy.GetAndPutIfAbsent(wrKey, wrValIn, rdValOut);
603 return proxy.Query(qry);
626 using namespace impl::thin::cache::query::continuous;
628 SP_ContinuousQueryClientHolderBase holder(
new ContinuousQueryClientHolder<K, V>(continuousQuery));
630 return proxy.QueryContinuous(holder, continuousQuery.
GetJavaFilter());
651 impl::thin::cache::CacheClientProxy proxy;
657 #endif // _IGNITE_THIN_CACHE_CACHE_CLIENT
void PutAll(InIter begin, InIter end)
Stores given key-value pairs in cache.
Definition: cache_client.h:123
Ignite API.
Definition: cache.h:47
void RemoveAll()
Removes all mappings from cache.
Definition: cache_client.h:367
ValueType GetAndRemove(const KeyType &key)
Atomically removes the entry for a key only if currently mapped to some value.
Definition: cache_client.h:478
~CacheClient()
Destructor.
Definition: cache_client.h:96
bool Remove(const KeyType &key)
Removes given key mapping from cache.
Definition: cache_client.h:312
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:355
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:514
Query fields cursor.
Definition: thin-client/include/ignite/thin/cache/query/query_fields_cursor.h:47
bool ContainsKeys(const Set &keys)
Check if cache contains mapping for these keys.
Definition: cache_client.h:266
int64_t GetSize(int32_t peekModes)
Gets the number of all entries cached across all nodes.
Definition: cache_client.h:295
Continuous query handle client.
Definition: thin-client/include/ignite/thin/cache/query/continuous/continuous_query_handle.h:42
SQL fields query for thin client.
Definition: thin-client/include/ignite/thin/cache/query/query_sql_fields.h:51
CacheClient(const common::concurrent::SharedPointer< void > &impl)
Constructor.
Definition: cache_client.h:79
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:586
void RemoveAll(const Set &keys)
Removes given key mappings from cache.
Definition: cache_client.h:342
bool ContainsKey(const KeyType &key)
Check if the cache contains a value for the specified key.
Definition: cache_client.h:252
query::continuous::ContinuousQueryHandleClient QueryContinuous(query::continuous::ContinuousQueryClient< K, V > continuousQuery)
Starts the continuous query execution.
Definition: cache_client.h:623
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:447
K KeyType
Key type.
Definition: cache_client.h:69
Cache client class template.
Definition: cache_client.h:63
query::QueryFieldsCursor Query(const query::SqlFieldsQuery &qry)
Perform SQL fields query.
Definition: cache_client.h:601
V ValueType
Value type.
Definition: cache_client.h:72
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:237
bool Get(const KeyType &key, ValueType &value)
Get value from the cache.
Definition: cache_client.h:149
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:531
CacheClient()
Default constructor.
Definition: cache_client.h:88
query::QueryCursor< KeyType, ValueType > Query(const query::ScanQuery &qry)
Perform scan query.
Definition: cache_client.h:612
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:429
void ClearAll(InIter begin, InIter end)
Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
Definition: cache_client.h:413
void Put(const KeyType &key, const ValueType &value)
Associate the specified value with the specified key in the cache.
Definition: cache_client.h:107
Scan query.
Definition: thin-client/include/ignite/thin/cache/query/query_scan.h:51
Query cursor class template.
Definition: thin-client/include/ignite/thin/cache/query/query_cursor.h:56
void GetAll(InIter begin, InIter end, OutIter dst)
Retrieves values mapped to the specified keys from cache.
Definition: cache_client.h:185
void GetAll(const Set &keys, Map &res)
Retrieves values mapped to the specified keys from cache.
Definition: cache_client.h:203
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:220
void Clear(const KeyType &key)
Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
Definition: cache_client.h:378
void PutAll(const Map &vals)
Stores given key-value pairs in cache.
Definition: cache_client.h:137
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:463
event::JavaCacheEntryEventFilter & GetJavaFilter()
Get remote Java filter reference.
Definition: continuous_query_client.h:230
void Clear()
Clear cache.
Definition: cache_client.h:388
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:496
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:558
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:35
void RefreshAffinityMapping()
Refresh affinity mapping.
Definition: cache_client.h:644
bool ContainsKeys(InIter begin, InIter end)
Check if cache contains mapping for these keys.
Definition: cache_client.h:279
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:327
void ClearAll(const Set &keys)
Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
Definition: cache_client.h:400
ValueType Get(const KeyType &key)
Get value from cache.
Definition: cache_client.h:165