23 #ifndef _IGNITE_THIN_CACHE_CACHE_CLIENT 24 #define _IGNITE_THIN_CACHE_CACHE_CLIENT 26 #include <ignite/common/concurrent.h> 28 #include <ignite/impl/thin/writable.h> 29 #include <ignite/impl/thin/writable_key.h> 30 #include <ignite/impl/thin/readable.h> 32 #include <ignite/impl/thin/cache/cache_client_proxy.h> 55 template<
typename K,
typename V>
58 friend class impl::thin::cache::CacheClientProxy;
100 void Put(
const KeyType& key,
const ValueType& value)
102 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
103 impl::thin::WritableImpl<ValueType> wrValue(value);
105 proxy.Put(wrKey, wrValue);
115 template<
typename InIter>
118 impl::thin::WritableMapImpl<K, V, InIter> wrSeq(begin, end);
129 template<
typename Map>
132 PutAll(vals.begin(), vals.end());
141 void Get(
const KeyType& key, ValueType& value)
143 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
144 impl::thin::ReadableImpl<ValueType> rdValue(value);
146 proxy.Get(wrKey, rdValue);
155 ValueType
Get(
const KeyType& key)
174 template<
typename InIter,
typename OutIter>
175 void GetAll(InIter begin, InIter end, OutIter dst)
177 impl::thin::WritableSetImpl<K, InIter> wrSeq(begin, end);
178 impl::thin::ReadableMapImpl<K, V, OutIter> rdSeq(dst);
180 proxy.GetAll(wrSeq, rdSeq);
192 template<
typename Set,
typename Map>
195 return GetAll(keys.begin(), keys.end(), std::inserter(res, res.end()));
212 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
213 impl::thin::WritableImpl<ValueType> wrValue(value);
215 return proxy.Replace(wrKey, wrValue);
227 bool Replace(
const KeyType& key,
const ValueType& oldVal,
const ValueType& newVal)
229 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
230 impl::thin::WritableImpl<ValueType> wrOldVal(oldVal);
231 impl::thin::WritableImpl<ValueType> wrNewVal(newVal);
233 return proxy.Replace(wrKey, wrOldVal, wrNewVal);
244 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
246 return proxy.ContainsKey(wrKey);
255 template<
typename Set>
268 template<
typename InIter>
271 impl::thin::WritableSetImpl<K, InIter> wrSeq(begin, end);
273 return proxy.ContainsKeys(wrSeq);
287 return proxy.GetSize(peekModes);
304 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
306 return proxy.Remove(wrKey);
317 bool Remove(
const KeyType& key,
const ValueType& val)
319 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
320 impl::thin::WritableImpl<ValueType> wrVal(val);
322 return proxy.Remove(wrKey, wrVal);
331 template<
typename Set>
344 template<
typename InIter>
347 impl::thin::WritableSetImpl<K, InIter> wrSeq(begin, end);
349 proxy.RemoveAll(wrSeq);
370 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
389 template<
typename Set>
402 template<
typename InIter>
405 impl::thin::WritableSetImpl<K, InIter> wrSeq(begin, end);
407 proxy.ClearAll(wrSeq);
419 void GetAndPut(
const KeyType& key,
const ValueType& valIn, ValueType& valOut)
421 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
422 impl::thin::WritableImpl<ValueType> wrValIn(valIn);
423 impl::thin::ReadableImpl<ValueType> rdValOut(valOut);
425 proxy.GetAndPut(wrKey, wrValIn, rdValOut);
437 ValueType
GetAndPut(
const KeyType& key,
const ValueType& valIn)
455 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
456 impl::thin::ReadableImpl<ValueType> rdValOut(valOut);
458 proxy.GetAndRemove(wrKey, rdValOut);
486 void GetAndReplace(
const KeyType& key,
const ValueType& valIn, ValueType& valOut)
488 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
489 impl::thin::WritableImpl<ValueType> wrValIn(valIn);
490 impl::thin::ReadableImpl<ValueType> rdValOut(valOut);
492 proxy.GetAndReplace(wrKey, wrValIn, rdValOut);
523 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
524 impl::thin::WritableImpl<ValueType> wrValIn(val);
526 return proxy.PutIfAbsent(wrKey, wrValIn);
550 impl::thin::WritableKeyImpl<KeyType> wrKey(key);
551 impl::thin::WritableImpl<ValueType> wrValIn(valIn);
552 impl::thin::ReadableImpl<ValueType> rdValOut(valOut);
554 proxy.GetAndPutIfAbsent(wrKey, wrValIn, rdValOut);
603 impl::thin::cache::CacheClientProxy proxy;
609 #endif // _IGNITE_THIN_CACHE_CACHE_CLIENT V ValueType
Value type.
Definition: cache_client.h:65
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:453
void GetAll(InIter begin, InIter end, OutIter dst)
Retrieves values mapped to the specified keys from cache.
Definition: cache_client.h:175
void RemoveAll()
Removes all mappings from cache.
Definition: cache_client.h:357
CacheClient(common::concurrent::SharedPointer< void > impl)
Constructor.
Definition: cache_client.h:72
ValueType GetAndRemove(const KeyType &key)
Atomically removes the entry for a key only if currently mapped to some value.
Definition: cache_client.h:468
int64_t GetSize(int32_t peekModes)
Gets the number of all entries cached across all nodes.
Definition: cache_client.h:285
void RemoveAll(InIter begin, InIter end)
Removes given key mappings from cache.
Definition: cache_client.h:345
K KeyType
Key type.
Definition: cache_client.h:62
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:576
bool ContainsKeys(InIter begin, InIter end)
Check if cache contains mapping for these keys.
Definition: cache_client.h:269
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:504
~CacheClient()
Destructor.
Definition: cache_client.h:89
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:210
ValueType Get(const KeyType &key)
Get value from cache.
Definition: cache_client.h:155
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:317
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:548
void PutAll(const Map &vals)
Stores given key-value pairs in cache.
Definition: cache_client.h:130
void PutAll(InIter begin, InIter end)
Stores given key-value pairs in cache.
Definition: cache_client.h:116
CacheClient()
Default constructor.
Definition: cache_client.h:81
bool ContainsKeys(const Set &keys)
Check if cache contains mapping for these keys.
Definition: cache_client.h:256
void Clear(const KeyType &key)
Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
Definition: cache_client.h:368
void Put(const KeyType &key, const ValueType &value)
Associate the specified value with the specified key in the cache.
Definition: cache_client.h:100
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:419
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:227
void RefreshAffinityMapping()
Refresh affinity mapping.
Definition: cache_client.h:596
void GetAll(const Set &keys, Map &res)
Retrieves values mapped to the specified keys from cache.
Definition: cache_client.h:193
Cache client class template.
Definition: cache_client.h:56
bool Remove(const KeyType &key)
Removes given key mapping from cache.
Definition: cache_client.h:302
void RemoveAll(const Set &keys)
Removes given key mappings from cache.
Definition: cache_client.h:332
void ClearAll(InIter begin, InIter end)
Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
Definition: cache_client.h:403
Apache Ignite API.
Definition: cache.h:48
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:486
bool ContainsKey(const KeyType &key)
Check if the cache contains a value for the specified key.
Definition: cache_client.h:242
void ClearAll(const Set &keys)
Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
Definition: cache_client.h:390
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:521
void Clear()
Clear cache.
Definition: cache_client.h:378
void Get(const KeyType &key, ValueType &value)
Get value from the cache.
Definition: cache_client.h:141
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:437