23 #ifndef _IGNITE_CACHE_CACHE
24 #define _IGNITE_CACHE_CACHE
29 #include <ignite/common/common.h>
30 #include <ignite/common/concurrent.h>
40 #include "ignite/impl/cache/cache_impl.h"
41 #include "ignite/impl/operations.h"
59 template<
typename K,
typename V>
60 class IGNITE_IMPORT_EXPORT
Cache
70 Cache(impl::cache::CacheImpl* impl) :
85 return impl.Get()->GetName();
100 bool res = IsEmpty(err);
118 return Size(err) == 0;
133 bool res = ContainsKey(key, err);
151 impl::In1Operation<K> op(&key);
153 return impl.Get()->ContainsKey(op, &err);
168 bool res = ContainsKeys(keys, err);
186 impl::InSetOperation<K> op(&keys);
188 return impl.Get()->ContainsKeys(op, &err);
208 V res = LocalPeek(key, peekModes, err);
231 impl::InCacheLocalPeekOperation<K> inOp(&key, peekModes);
232 impl::Out1Operation<V> outOp;
234 impl.Get()->LocalPeek(inOp, outOp, peekModes, &err);
236 return outOp.GetResult();
255 V res = Get(key, err);
277 impl::In1Operation<K> inOp(&key);
278 impl::Out1Operation<V> outOp;
280 impl.Get()->Get(inOp, outOp, &err);
282 return outOp.GetResult();
297 std::map<K, V>
GetAll(
const std::set<K>& keys)
301 std::map<K, V> res = GetAll(keys, err);
323 impl::InSetOperation<K> inOp(&keys);
324 impl::OutMapOperation<K, V> outOp;
326 impl.Get()->GetAll(inOp, outOp, &err);
328 return outOp.GetResult();
341 void Put(
const K& key,
const V& val)
363 impl::In2Operation<K, V> op(&key, &val);
365 impl.Get()->Put(op, &err);
398 impl::InMapOperation<K, V> op(&vals);
400 impl.Get()->PutAll(op, &err);
418 V res = GetAndPut(key, val, err);
439 impl::In2Operation<K, V> inOp(&key, &val);
440 impl::Out1Operation<V> outOp;
442 impl.Get()->GetAndPut(inOp, outOp, &err);
444 return outOp.GetResult();
462 V res = GetAndReplace(key, val, err);
483 impl::In2Operation<K, V> inOp(&key, &val);
484 impl::Out1Operation<V> outOp;
486 impl.Get()->GetAndReplace(inOp, outOp, &err);
488 return outOp.GetResult();
503 V res = GetAndRemove(key, err);
521 impl::In1Operation<K> inOp(&key);
522 impl::Out1Operation<V> outOp;
524 impl.Get()->GetAndRemove(inOp, outOp, &err);
526 return outOp.GetResult();
543 bool res = PutIfAbsent(key, val, err);
563 impl::In2Operation<K, V> op(&key, &val);
565 return impl.Get()->PutIfAbsent(op, &err);
590 V res = GetAndPutIfAbsent(key, val, err);
618 impl::In2Operation<K, V> inOp(&key, &val);
619 impl::Out1Operation<V> outOp;
621 impl.Get()->GetAndPutIfAbsent(inOp, outOp, &err);
623 return outOp.GetResult();
645 bool res = Replace(key, val, err);
670 impl::In2Operation<K, V> op(&key, &val);
672 return impl.Get()->Replace(op, &err);
687 bool Replace(
const K& key,
const V& oldVal,
const V& newVal)
691 bool res = Replace(key, oldVal, newVal, err);
713 impl::In3Operation<K, V, V> op(&key, &oldVal, &newVal);
715 return impl.Get()->ReplaceIfEqual(op, &err);
732 LocalEvict(keys, err);
750 impl::InSetOperation<K> op(&keys);
752 impl.Get()->LocalEvict(op, &err);
778 impl.Get()->Clear(&err);
809 impl::In1Operation<K> op(&key);
811 impl.Get()->Clear(op, &err);
842 impl::InSetOperation<K> op(&keys);
844 impl.Get()->ClearAll(op, &err);
862 LocalClear(key, err);
881 impl::In1Operation<K> op(&key);
883 impl.Get()->LocalClear(op, &err);
901 LocalClearAll(keys, err);
920 impl::InSetOperation<K> op(&keys);
922 impl.Get()->LocalClearAll(op, &err);
944 bool res = Remove(key, err);
969 impl::In1Operation<K> op(&key);
971 return impl.Get()->Remove(op, &err);
989 bool res = Remove(key, val, err);
1010 impl::In2Operation<K, V> op(&key, &val);
1012 return impl.Get()->RemoveIfEqual(op, &err);
1028 RemoveAll(keys, err);
1045 impl::InSetOperation<K> op(&keys);
1047 impl.Get()->RemoveAll(op, &err);
1078 return impl.Get()->RemoveAll(&err);
1118 int32_t res = LocalSize(peekModes, err);
1136 return impl.Get()->Size(peekModes,
true, &err);
1179 int32_t res = Size(peekModes, err);
1198 return impl.Get()->Size(peekModes,
false, &err);
1231 impl::cache::query::QueryCursorImpl* cursorImpl = impl.Get()->QuerySql(qry, &err);
1266 impl::cache::query::QueryCursorImpl* cursorImpl = impl.Get()->QueryText(qry, &err);
1301 impl::cache::query::QueryCursorImpl* cursorImpl = impl.Get()->QueryScan(qry, &err);
1336 impl::cache::query::QueryCursorImpl* cursorImpl = impl.Get()->QuerySqlFields(qry, &err);
1354 return impl.IsValid();
1359 ignite::common::concurrent::SharedPointer<impl::cache::CacheImpl> impl;
1364 #endif //_IGNITE_CACHE_CACHE
const char * GetName() const
Get name of this cache (null for default cache).
Definition: cache.h:83
query::QueryCursor< K, V > Query(const query::TextQuery &qry)
Perform text query.
Definition: cache.h:1244
void ClearAll(const std::set< K > &keys)
Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
Definition: cache.h:822
Text query.
Definition: query_text.h:40
void Clear()
Clear cache.
Definition: cache.h:760
V GetAndPut(const K &key, const V &val, IgniteError &err)
Associates the specified value with the specified key in this cache, returning an existing value if o...
Definition: cache.h:437
int32_t LocalSize(int32_t peekModes)
Gets the number of all entries cached on this node.
Definition: cache.h:1114
void LocalClearAll(const std::set< K > &keys, IgniteError &err)
Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
Definition: cache.h:918
Declares ignite::cache::query::QueryCursor class template.
bool Remove(const K &key, const V &val)
Removes given key mapping from cache if one exists and value is equal to the passed in value...
Definition: cache.h:985
Declares ignite::cache::query::QueryFieldsCursor class.
Declares ignite::cache::query::SqlQuery class.
void Clear(const K &key)
Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
Definition: cache.h:789
Main entry point for all Data Grid APIs.
Definition: cache.h:60
Declares ignite::cache::CachePeekMode enum.
bool Remove(const K &key, const V &val, IgniteError &err)
Removes given key mapping from cache if one exists and value is equal to the passed in value...
Definition: cache.h:1008
int32_t Size()
Gets the number of all entries cached across all nodes.
Definition: cache.h:1147
bool ContainsKeys(const std::set< K > &keys)
Check if cache contains mapping for these keys.
Definition: cache.h:164
query::QueryCursor< K, V > Query(const query::SqlQuery &qry)
Perform SQL query.
Definition: cache.h:1209
void Clear(const K &key, IgniteError &err)
Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
Definition: cache.h:807
V GetAndPutIfAbsent(const K &key, const V &val, IgniteError &err)
Stores given key-value pair in cache only if cache had no previous mapping for it.
Definition: cache.h:616
Cache(impl::cache::CacheImpl *impl)
Constructor.
Definition: cache.h:70
bool Remove(const K &key)
Removes given key mapping from cache.
Definition: cache.h:940
bool IsEmpty(IgniteError &err)
Checks whether this cache contains no key-value mappings.
Definition: cache.h:116
void Clear(IgniteError &err)
Clear cache.
Definition: cache.h:776
bool ContainsKeys(const std::set< K > &keys, IgniteError &err)
Check if cache contains mapping for these keys.
Definition: cache.h:184
V Get(const K &key, IgniteError &err)
Retrieves value mapped to the specified key from cache.
Definition: cache.h:275
void RemoveAll()
Removes all mappings from cache.
Definition: cache.h:1058
Scan query.
Definition: query_scan.h:40
Sql query.
Definition: query_sql.h:42
query::QueryCursor< K, V > Query(const query::ScanQuery &qry)
Perform scan query.
Definition: cache.h:1279
query::QueryCursor< K, V > Query(const query::SqlQuery &qry, IgniteError &err)
Perform SQL query.
Definition: cache.h:1229
V GetAndRemove(const K &key, IgniteError &err)
Atomically removes the entry for a key only if currently mapped to some value.
Definition: cache.h:519
V LocalPeek(const K &key, int32_t peekModes)
Peeks at cached value using optional set of peek modes.
Definition: cache.h:204
void RemoveAll(const std::set< K > &keys)
Removes given key mappings from cache.
Definition: cache.h:1024
bool Replace(const K &key, const V &oldVal, const V &newVal, IgniteError &err)
Stores given key-value pair in cache only if only if the previous value is equal to the old value pas...
Definition: cache.h:711
void ClearAll(const std::set< K > &keys, IgniteError &err)
Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
Definition: cache.h:840
V GetAndPut(const K &key, const V &val)
Associates the specified value with the specified key in this cache, returning an existing value if o...
Definition: cache.h:414
Sql fields query.
Definition: query_sql_fields.h:42
bool ContainsKey(const K &key)
Check if cache contains mapping for this key.
Definition: cache.h:129
void LocalClear(const K &key)
Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
Definition: cache.h:858
int32_t Size(IgniteError &err)
Gets the number of all entries cached across all nodes.
Definition: cache.h:1161
bool IsEmpty()
Checks whether this cache contains no key-value mappings.
Definition: cache.h:96
bool IsValid() const
Check if the instance is valid.
Definition: cache.h:1352
void RemoveAll(const std::set< K > &keys, IgniteError &err)
Removes given key mappings from cache.
Definition: cache.h:1043
void PutAll(const std::map< K, V > &vals)
Stores given key-value pairs in cache.
Definition: cache.h:377
void LocalEvict(const std::set< K > &keys, IgniteError &err)
Attempts to evict all entries associated with keys.
Definition: cache.h:748
V GetAndRemove(const K &key)
Atomically removes the entry for a key only if currently mapped to some value.
Definition: cache.h:499
Peeks into all available cache storages.
Definition: cache_peek_mode.h:38
Query fields cursor.
Definition: query_fields_cursor.h:50
V Get(const K &key)
Retrieves value mapped to the specified key from cache.
Definition: cache.h:251
void Put(const K &key, const V &val)
Associates the specified value with the specified key in the cache.
Definition: cache.h:341
void LocalEvict(const std::set< K > &keys)
Attempts to evict all entries associated with keys.
Definition: cache.h:728
bool Replace(const K &key, const V &oldVal, const V &newVal)
Stores given key-value pair in cache only if only if the previous value is equal to the old value pas...
Definition: cache.h:687
int32_t Size(int32_t peekModes, IgniteError &err)
Gets the number of all entries cached across all nodes.
Definition: cache.h:1196
bool PutIfAbsent(const K &key, const V &val)
Atomically associates the specified key with the given value if it is not already associated with a v...
Definition: cache.h:539
bool Replace(const K &key, const V &val, IgniteError &err)
Stores given key-value pair in cache only if there is a previous mapping for it.
Definition: cache.h:668
int32_t Size(int32_t peekModes)
Gets the number of all entries cached across all nodes.
Definition: cache.h:1175
std::map< K, V > GetAll(const std::set< K > &keys)
Retrieves values mapped to the specified keys from cache.
Definition: cache.h:297
V GetAndReplace(const K &key, const V &val, IgniteError &err)
Atomically replaces the value for a given key if and only if there is a value currently mapped by the...
Definition: cache.h:481
bool ContainsKey(const K &key, IgniteError &err)
Check if cache contains mapping for this key.
Definition: cache.h:149
void PutAll(const std::map< K, V > &vals, IgniteError &err)
Stores given key-value pairs in cache.
Definition: cache.h:396
V LocalPeek(const K &key, int32_t peekModes, IgniteError &err)
Peeks at cached value using optional set of peek modes.
Definition: cache.h:229
int32_t LocalSize(IgniteError &err)
Gets the number of all entries cached on this node.
Definition: cache.h:1101
Declares ignite::cache::query::SqlFieldsQuery class.
Ignite error information.
Definition: ignite_error.h:94
V GetAndPutIfAbsent(const K &key, const V &val)
Stores given key-value pair in cache only if cache had no previous mapping for it.
Definition: cache.h:586
void LocalClearAll(const std::set< K > &keys)
Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
Definition: cache.h:897
Declares ignite::cache::query::ScanQuery class.
bool PutIfAbsent(const K &key, const V &val, IgniteError &err)
Atomically associates the specified key with the given value if it is not already associated with a v...
Definition: cache.h:561
void Put(const K &key, const V &val, IgniteError &err)
Associates the specified value with the specified key in the cache.
Definition: cache.h:361
V GetAndReplace(const K &key, const V &val)
Atomically replaces the value for a given key if and only if there is a value currently mapped by the...
Definition: cache.h:458
query::QueryCursor< K, V > Query(const query::ScanQuery &qry, IgniteError &err)
Perform scan query.
Definition: cache.h:1299
Apache Ignite API.
Definition: cache.h:43
query::QueryCursor< K, V > Query(const query::TextQuery &qry, IgniteError &err)
Perform text query.
Definition: cache.h:1264
Declares ignite::IgniteError class.
query::QueryFieldsCursor Query(const query::SqlFieldsQuery &qry, IgniteError &err)
Perform sql fields query.
Definition: cache.h:1334
bool Replace(const K &key, const V &val)
Stores given key-value pair in cache only if there is a previous mapping for it.
Definition: cache.h:641
query::QueryFieldsCursor Query(const query::SqlFieldsQuery &qry)
Perform sql fields query.
Definition: cache.h:1314
Query cursor class template.
Definition: query_cursor.h:54
static void ThrowIfNeeded(const IgniteError &err)
Throw an error if code is not IGNITE_SUCCESS.
Definition: ignite_error.cpp:27
void RemoveAll(IgniteError &err)
Removes all mappings from cache.
Definition: cache.h:1076
std::map< K, V > GetAll(const std::set< K > &keys, IgniteError &err)
Retrieves values mapped to the specified keys from cache.
Definition: cache.h:321
int32_t LocalSize()
Gets the number of all entries cached on this node.
Definition: cache.h:1088
bool Remove(const K &key, IgniteError &err)
Removes given key mapping from cache.
Definition: cache.h:967
void LocalClear(const K &key, IgniteError &err)
Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
Definition: cache.h:879
Declares ignite::cache::query::TextQuery class.
int32_t LocalSize(int32_t peekModes, IgniteError &err)
Gets the number of all entries cached on this node.
Definition: cache.h:1134