29 #include <ignite/common/common.h>
30 #include <ignite/common/concurrent.h>
39 #include "ignite/impl/cache/cache_impl.h"
40 #include "ignite/impl/operations.h"
50 template<
typename K,
typename V>
51 class IGNITE_IMPORT_EXPORT
Cache
57 Cache(impl::cache::CacheImpl* impl) : impl(
ignite::common::concurrent::SharedPointer<impl::cache::CacheImpl>(impl))
67 return impl.Get()->GetName();
80 bool res = IsEmpty(err);
96 return impl.Get()->IsEmpty(&err);
109 bool res = ContainsKey(key, err);
125 impl::In1Operation<K> op(&key);
127 return impl.Get()->ContainsKey(op, &err);
140 bool res = ContainsKeys(keys, err);
156 impl::InSetOperation<K> op(&keys);
158 return impl.Get()->ContainsKeys(op, &err);
176 V res = LocalPeek(key, peekModes, err);
197 impl::InCacheLocalPeekOperation<K> inOp(&key, peekModes);
198 impl::Out1Operation<V> outOp;
200 impl.Get()->LocalPeek(inOp, outOp, peekModes, &err);
202 return outOp.GetResult();
219 V res = Get(key, err);
239 impl::In1Operation<K> inOp(&key);
240 impl::Out1Operation<V> outOp;
242 impl.Get()->Get(inOp, outOp, &err);
244 return outOp.GetResult();
257 std::map<K, V>
GetAll(
const std::set<K>& keys)
261 std::map<K, V> res = GetAll(keys, err);
281 impl::InSetOperation<K> inOp(&keys);
282 impl::OutMapOperation<K, V> outOp;
284 impl.Get()->GetAll(inOp, outOp, &err);
286 return outOp.GetResult();
297 void Put(
const K& key,
const V& val)
317 impl::In2Operation<K, V> op(&key, &val);
319 impl.Get()->Put(op, &err);
348 impl::InMapOperation<K, V> op(&vals);
350 impl.Get()->PutAll(op, &err);
366 V res = GetAndPut(key, val, err);
385 impl::In2Operation<K, V> inOp(&key, &val);
386 impl::Out1Operation<V> outOp;
388 impl.Get()->GetAndPut(inOp, outOp, &err);
390 return outOp.GetResult();
406 V res = GetAndReplace(key, val, err);
425 impl::In2Operation<K, V> inOp(&key, &val);
426 impl::Out1Operation<V> outOp;
428 impl.Get()->GetAndReplace(inOp, outOp, &err);
430 return outOp.GetResult();
443 V res = GetAndRemove(key, err);
459 impl::In1Operation<K> inOp(&key);
460 impl::Out1Operation<V> outOp;
462 impl.Get()->GetAndRemove(inOp, outOp, &err);
464 return outOp.GetResult();
479 bool res = PutIfAbsent(key, val, err);
497 impl::In2Operation<K, V> op(&key, &val);
499 return impl.Get()->PutIfAbsent(op, &err);
522 V res = GetAndPutIfAbsent(key, val, err);
548 impl::In2Operation<K, V> inOp(&key, &val);
549 impl::Out1Operation<V> outOp;
551 impl.Get()->GetAndPutIfAbsent(inOp, outOp, &err);
553 return outOp.GetResult();
573 bool res = Replace(key, val, err);
596 impl::In2Operation<K, V> op(&key, &val);
598 return impl.Get()->Replace(op, &err);
611 bool Replace(
const K& key,
const V& oldVal,
const V& newVal)
615 bool res = Replace(key, oldVal, newVal, err);
635 impl::In3Operation<K, V, V> op(&key, &oldVal, &newVal);
637 return impl.Get()->ReplaceIfEqual(op, &err);
650 LocalEvict(keys, err);
664 impl::InSetOperation<K> op(&keys);
666 impl.Get()->LocalEvict(op, &err);
688 impl.Get()->Clear(&err);
715 impl::In1Operation<K> op(&key);
717 impl.Get()->Clear(op, &err);
744 impl::InSetOperation<K> op(&keys);
746 impl.Get()->ClearAll(op, &err);
761 LocalClear(key, err);
777 impl::In1Operation<K> op(&key);
779 impl.Get()->LocalClear(op, &err);
794 LocalClearAll(keys, err);
810 impl::InSetOperation<K> op(&keys);
812 impl.Get()->LocalClearAll(op, &err);
832 bool res = Remove(key, err);
855 impl::In1Operation<K> op(&key);
857 return impl.Get()->Remove(op, &err);
873 bool res = Remove(key, val, err);
892 impl::In2Operation<K, V> op(&key, &val);
894 return impl.Get()->RemoveIfEqual(op, &err);
908 RemoveAll(keys, err);
923 impl::InSetOperation<K> op(&keys);
925 impl.Get()->RemoveAll(op, &err);
953 return impl.Get()->RemoveAll(&err);
987 int32_t res = LocalSize(peekModes, err);
1003 return impl.Get()->LocalSize(peekModes, &err);
1040 int32_t res = Size(peekModes, err);
1057 return impl.Get()->Size(peekModes, &err);
1086 impl::cache::query::QueryCursorImpl* cursorImpl = impl.Get()->QuerySql(qry, &err);
1117 impl::cache::query::QueryCursorImpl* cursorImpl = impl.Get()->QueryText(qry, &err);
1148 impl::cache::query::QueryCursorImpl* cursorImpl = impl.Get()->QueryScan(qry, &err);
1179 impl::cache::query::QueryCursorImpl* cursorImpl = impl.Get()->QuerySqlFields(qry, &err);
1191 return impl.IsValid();
1196 ignite::common::concurrent::SharedPointer<impl::cache::CacheImpl> impl;
const char * GetName() const
Name of this cache (null for default cache).
Definition: cache.h:65
query::QueryCursor< K, V > Query(const query::TextQuery &qry)
Perform text query.
Definition: cache.h:1097
void ClearAll(const std::set< K > &keys)
Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
Definition: cache.h:726
Text query.
Definition: query_text.h:40
void Clear()
Clear cache.
Definition: cache.h:672
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:383
int32_t LocalSize(int32_t peekModes)
Gets the number of all entries cached on this node.
Definition: cache.h:983
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:808
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:869
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:697
Main entry point for all Data Grid APIs.
Definition: cache.h:51
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:890
int32_t Size()
Gets the number of all entries cached across all nodes.
Definition: cache.h:1012
bool ContainsKeys(const std::set< K > &keys)
Check if cache contains mapping for these keys.
Definition: cache.h:136
query::QueryCursor< K, V > Query(const query::SqlQuery &qry)
Perform SQL query.
Definition: cache.h:1066
void Clear(const K &key, IgniteError &err)
Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
Definition: cache.h:713
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:546
Cache(impl::cache::CacheImpl *impl)
Constructor.
Definition: cache.h:57
bool Remove(const K &key)
Removes given key mapping from cache.
Definition: cache.h:828
bool IsEmpty(IgniteError &err)
Checks whether this cache contains no key-value mappings.
Definition: cache.h:94
void Clear(IgniteError &err)
Clear cache.
Definition: cache.h:686
bool ContainsKeys(const std::set< K > &keys, IgniteError &err)
Check if cache contains mapping for these keys.
Definition: cache.h:154
V Get(const K &key, IgniteError &err)
Retrieves value mapped to the specified key from cache.
Definition: cache.h:237
void RemoveAll()
Removes all mappings from cache.
Definition: cache.h:935
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:1128
query::QueryCursor< K, V > Query(const query::SqlQuery &qry, IgniteError &err)
Perform SQL query.
Definition: cache.h:1084
V GetAndRemove(const K &key, IgniteError &err)
Atomically removes the entry for a key only if currently mapped to some value.
Definition: cache.h:457
V LocalPeek(const K &key, int32_t peekModes)
Peeks at cached value using optional set of peek modes.
Definition: cache.h:172
void RemoveAll(const std::set< K > &keys)
Removes given key mappings from cache.
Definition: cache.h:904
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:633
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:742
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:362
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:105
bool IsValid()
Check if the instance is valid.
Definition: cache.h:1189
void LocalClear(const K &key)
Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
Definition: cache.h:757
int32_t Size(IgniteError &err)
Gets the number of all entries cached across all nodes.
Definition: cache.h:1024
bool IsEmpty()
Checks whether this cache contains no key-value mappings.
Definition: cache.h:76
void RemoveAll(const std::set< K > &keys, IgniteError &err)
Removes given key mappings from cache.
Definition: cache.h:921
void PutAll(const std::map< K, V > &vals)
Stores given key-value pairs in cache.
Definition: cache.h:329
void LocalEvict(const std::set< K > &keys, IgniteError &err)
Attempts to evict all entries associated with keys.
Definition: cache.h:662
V GetAndRemove(const K &key)
Atomically removes the entry for a key only if currently mapped to some value.
Definition: cache.h:439
Peeks into all available cache storages.
Definition: cache_peek_mode.h:38
Query fields cursor.
Definition: query_fields_cursor.h:45
V Get(const K &key)
Retrieves value mapped to the specified key from cache.
Definition: cache.h:215
void Put(const K &key, const V &val)
Associates the specified value with the specified key in the cache.
Definition: cache.h:297
void LocalEvict(const std::set< K > &keys)
Attempts to evict all entries associated with keys.
Definition: cache.h:646
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:611
int32_t Size(int32_t peekModes, IgniteError &err)
Gets the number of all entries cached across all nodes.
Definition: cache.h:1055
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:475
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:594
int32_t Size(int32_t peekModes)
Gets the number of all entries cached across all nodes.
Definition: cache.h:1036
std::map< K, V > GetAll(const std::set< K > &keys)
Retrieves values mapped to the specified keys from cache.
Definition: cache.h:257
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:423
static void ThrowIfNeeded(IgniteError &err)
Throw an error if code is not IGNITE_SUCCESS.
Definition: ignite_error.cpp:27
bool ContainsKey(const K &key, IgniteError &err)
Check if cache contains mapping for this key.
Definition: cache.h:123
void PutAll(const std::map< K, V > &vals, IgniteError &err)
Stores given key-value pairs in cache.
Definition: cache.h:346
V LocalPeek(const K &key, int32_t peekModes, IgniteError &err)
Peeks at cached value using optional set of peek modes.
Definition: cache.h:195
int32_t LocalSize(IgniteError &err)
Gets the number of all entries cached on this node.
Definition: cache.h:972
Declares ignite::cache::query::SqlFieldsQuery class.
Ignite error information.
Definition: ignite_error.h:78
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:518
void LocalClearAll(const std::set< K > &keys)
Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
Definition: cache.h:790
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:495
void Put(const K &key, const V &val, IgniteError &err)
Associates the specified value with the specified key in the cache.
Definition: cache.h:315
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:402
query::QueryCursor< K, V > Query(const query::ScanQuery &qry, IgniteError &err)
Perform scan query.
Definition: cache.h:1146
Apache Ignite API.
Definition: binary_consts.h:28
query::QueryCursor< K, V > Query(const query::TextQuery &qry, IgniteError &err)
Perform text query.
Definition: cache.h:1115
Declares ignite::IgniteError class.
query::QueryFieldsCursor Query(const query::SqlFieldsQuery &qry, IgniteError &err)
Perform sql fields query.
Definition: cache.h:1177
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:569
query::QueryFieldsCursor Query(const query::SqlFieldsQuery &qry)
Perform sql fields query.
Definition: cache.h:1159
Query cursor.
Definition: query_cursor.h:45
void RemoveAll(IgniteError &err)
Removes all mappings from cache.
Definition: cache.h:951
std::map< K, V > GetAll(const std::set< K > &keys, IgniteError &err)
Retrieves values mapped to the specified keys from cache.
Definition: cache.h:279
int32_t LocalSize()
Gets the number of all entries cached on this node.
Definition: cache.h:961
bool Remove(const K &key, IgniteError &err)
Removes given key mapping from cache.
Definition: cache.h:853
void LocalClear(const K &key, IgniteError &err)
Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
Definition: cache.h:775
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:1001