| Apache Ignite C++

Public Member Functions | List of all members
ignite::cache::Cache< K, V > Class Template Reference

Main entry point for all Data Grid APIs. More...

`#include <cache.h>`

## Public Member Functions
| Cache (impl::cache::CacheImpl *impl)
| Constructor. More...
const char * | GetName () const
| Get name of this cache (null for default cache). More...
bool | IsEmpty ()
| Checks whether this cache contains no key-value mappings. More...
bool | IsEmpty (IgniteError &err)
| Checks whether this cache contains no key-value mappings. More...
bool | ContainsKey (const K &key)
| Check if cache contains mapping for this key. More...
bool | ContainsKey (const K &key, IgniteError &err)
| Check if cache contains mapping for this key. More...
bool | ContainsKeys (const std::set< K > &keys)
| Check if cache contains mapping for these keys. More...
template<typename InputIter >
bool | ContainsKeys (InputIter begin, InputIter end)
| Check if cache contains mapping for these keys. More...
bool | ContainsKeys (const std::set< K > &keys, IgniteError &err)
| Check if cache contains mapping for these keys. More...
V | LocalPeek (const K &key, int32_t peekModes)
| Peeks at cached value using optional set of peek modes. More...
V | LocalPeek (const K &key, int32_t peekModes, IgniteError &err)
| Peeks at cached value using optional set of peek modes. More...
V | Get (const K &key)
| Retrieves value mapped to the specified key from cache. More...
V | Get (const K &key, IgniteError &err)
| Retrieves value mapped to the specified key from cache. More...
std::map< K, V > | GetAll (const std::set< K > &keys)
| Retrieves values mapped to the specified keys from cache. More...
std::map< K, V > | GetAll (const std::set< K > &keys, IgniteError &err)
| Retrieves values mapped to the specified keys from cache. More...
template<typename InIter , typename OutIter >
void | GetAll (InIter begin, InIter end, OutIter dst)
| Retrieves values mapped to the specified keys from cache. More...
void | Put (const K &key, const V &val)
| Associates the specified value with the specified key in the cache. More...
void | Put (const K &key, const V &val, IgniteError &err)
| Associates the specified value with the specified key in the cache. More...
void | PutAll (const std::map< K, V > &vals)
| Stores given key-value pairs in cache. More...
void | PutAll (const std::map< K, V > &vals, IgniteError &err)
| Stores given key-value pairs in cache. More...
template<typename Iter >
void | PutAll (Iter begin, Iter end)
| Stores given key-value pairs in cache. More...
V | GetAndPut (const K &key, const V &val)
| Associates the specified value with the specified key in this cache, returning an existing value if one existed. More...
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 one existed. More...
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 key. More...
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 key. More...
V | GetAndRemove (const K &key)
| Atomically removes the entry for a key only if currently mapped to some value. More...
V | GetAndRemove (const K &key, IgniteError &err)
| Atomically removes the entry for a key only if currently mapped to some value. More...
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 value. More...
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 value. More...
V | GetAndPutIfAbsent (const K &key, const V &val)
| Stores given key-value pair in cache only if cache had no previous mapping for it. More...
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. More...
bool | Replace (const K &key, const V &val)
| Stores given key-value pair in cache only if there is a previous mapping for it. More...
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. More...
bool | Replace (const K &key, const V &oldVal, const V &newVal)
| Stores given key-value pair in cache only if the previous value is equal to the old value passed as argument. More...
bool | Replace (const K &key, const V &oldVal, const V &newVal, IgniteError &err)
| Stores given key-value pair in cache only if the previous value is equal to the old value passed as argument. More...
void | LocalEvict (const std::set< K > &keys)
| Attempts to evict all entries associated with keys. More...
void | LocalEvict (const std::set< K > &keys, IgniteError &err)
| Attempts to evict all entries associated with keys. More...
template<typename Iter >
void | LocalEvict (Iter begin, Iter end)
| Attempts to evict all entries associated with keys. More...
void | Clear ()
| Clear cache. More...
void | Clear (IgniteError &err)
| Clear cache. More...
void | Clear (const K &key)
| Clear entry from the cache and swap storage, without notifying listeners or CacheWriters. More...
void | Clear (const K &key, IgniteError &err)
| Clear entry from the cache and swap storage, without notifying listeners or CacheWriters. More...
void | ClearAll (const std::set< K > &keys)
| Clear entries from the cache and swap storage, without notifying listeners or CacheWriters. More...
void | ClearAll (const std::set< K > &keys, IgniteError &err)
| Clear entries from the cache and swap storage, without notifying listeners or CacheWriters. More...
template<typename Iter >
void | ClearAll (Iter begin, Iter end)
| Clear entries from the cache and swap storage, without notifying listeners or CacheWriters. More...
void | LocalClear (const K &key)
| Clear entry from the cache and swap storage, without notifying listeners or CacheWriters. More...
void | LocalClear (const K &key, IgniteError &err)
| Clear entry from the cache and swap storage, without notifying listeners or CacheWriters. More...
void | LocalClearAll (const std::set< K > &keys)
| Clear entries from the cache and swap storage, without notifying listeners or CacheWriters. More...
void | LocalClearAll (const std::set< K > &keys, IgniteError &err)
| Clear entries from the cache and swap storage, without notifying listeners or CacheWriters. More...
template<typename Iter >
void | LocalClearAll (Iter begin, Iter end)
| Clear entries from the cache and swap storage, without notifying listeners or CacheWriters. More...
bool | Remove (const K &key)
| Removes given key mapping from cache. More...
bool | Remove (const K &key, IgniteError &err)
| Removes given key mapping from cache. More...
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. More...
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. More...
void | RemoveAll (const std::set< K > &keys)
| Removes given key mappings from cache. More...
void | RemoveAll (const std::set< K > &keys, IgniteError &err)
| Removes given key mappings from cache. More...
template<typename Iter >
void | RemoveAll (Iter begin, Iter end)
| Removes given key mappings from cache. More...
void | RemoveAll ()
| Removes all mappings from cache. More...
void | RemoveAll (IgniteError &err)
| Removes all mappings from cache. More...
int32_t | LocalSize ()
| Gets the number of all entries cached on this node. More...
int32_t | LocalSize (IgniteError &err)
| Gets the number of all entries cached on this node. More...
int32_t | LocalSize (int32_t peekModes)
| Gets the number of all entries cached on this node. More...
int32_t | LocalSize (int32_t peekModes, IgniteError &err)
| Gets the number of all entries cached on this node. More...
int32_t | Size ()
| Gets the number of all entries cached across all nodes. More...
int32_t | Size (IgniteError &err)
| Gets the number of all entries cached across all nodes. More...
int32_t | Size (int32_t peekModes)
| Gets the number of all entries cached across all nodes. More...
int32_t | Size (int32_t peekModes, IgniteError &err)
| Gets the number of all entries cached across all nodes. More...
query::QueryCursor< K, V > | Query (const query::SqlQuery &qry)
| Perform SQL query. More...
query::QueryCursor< K, V > | Query (const query::SqlQuery &qry, IgniteError &err)
| Perform SQL query. More...
query::QueryCursor< K, V > | Query (const query::TextQuery &qry)
| Perform text query. More...
query::QueryCursor< K, V > | Query (const query::TextQuery &qry, IgniteError &err)
| Perform text query. More...
query::QueryCursor< K, V > | Query (const query::ScanQuery &qry)
| Perform scan query. More...
query::QueryCursor< K, V > | Query (const query::ScanQuery &qry, IgniteError &err)
| Perform scan query. More...
query::QueryFieldsCursor | Query (const query::SqlFieldsQuery &qry)
| Perform sql fields query. More...
query::QueryFieldsCursor | Query (const query::SqlFieldsQuery &qry, IgniteError &err)
| Perform sql fields query. More...
template<typename R , typename P , typename A >
R | Invoke (const K &key, const P &processor, const A &arg)
| Invokes an CacheEntryProcessor against the MutableCacheEntry specified by the provided key. More...
template<typename R , typename P , typename A >
R | Invoke (const K &key, const P &processor, const A &arg, IgniteError &err)
| Invokes an CacheEntryProcessor against the MutableCacheEntry specified by the provided key. More...
query::continuous::ContinuousQueryHandle< K, V > | QueryContinuous (const query::continuous::ContinuousQuery< K, V > &qry)
| Start continuous query execution. More...
query::continuous::ContinuousQueryHandle< K, V > | QueryContinuous (const query::continuous::ContinuousQuery< K, V > &qry, IgniteError &err)
| Start continuous query execution. More...
template<typename Q >
query::continuous::ContinuousQueryHandle< K, V > | QueryContinuous (const query::continuous::ContinuousQuery< K, V > &qry, const Q &initialQry)
| Start continuous query execution with the initial query. More...
template<typename Q >
query::continuous::ContinuousQueryHandle< K, V > | QueryContinuous (const query::continuous::ContinuousQuery< K, V > &qry, const Q &initialQry, IgniteError &err)
| Start continuous query execution with the initial query. More...
bool | IsValid () const
| Check if the instance is valid. More...
void | LoadCache ()
| Executes LocalLoadCache on all cache nodes.
void | LocalLoadCache ()
| Loads state from the underlying persistent storage. More...

## Detailed Description

### template<typename K, typename V>
class ignite::cache::Cache< K, V >

Main entry point for all Data Grid APIs.

Both key and value types should be default-constructable, copy-constructable and assignable. Also BinaryType class template should be specialized for both types.

This class is implemented as a reference to an implementation so copying of this class instance will only create another reference to the same underlying object. Underlying object will be released automatically once all the instances are destructed.

Template Parameters

  K | Cache key type.
  V | Cache value type.

## Constructor & Destructor Documentation

## ◆ Cache()

template<typename K, typename V>

ignite::cache::Cache< K, V >::Cache | ( | impl::cache::CacheImpl * | impl | ) |
| inline

Constructor.

Internal method. Should not be used by user.

Parameters

  impl | Implementation.

## Member Function Documentation

## ◆ Clear() [1/4]

template<typename K, typename V>

void ignite::cache::Cache< K, V >::Clear | ( |  | ) |
| inline

Clear cache.

This method should only be used on the valid instance.

## ◆ Clear() [2/4]

template<typename K, typename V>

void ignite::cache::Cache< K, V >::Clear | ( | IgniteError & | err | ) |
| inline

Clear cache.

This method should only be used on the valid instance.

Parameters

  err | Error.

## ◆ Clear() [3/4]

template<typename K, typename V>

void ignite::cache::Cache< K, V >::Clear | ( | const K & | key | ) |
| inline

Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.

Entry is cleared only if it is not currently locked, and is not participating in a transaction.

This method should only be used on the valid instance.

Parameters

  key | Key to clear.

## ◆ Clear() [4/4]

template<typename K, typename V>

void ignite::cache::Cache< K, V >::Clear | ( | const K & | key,
|  | IgniteError & | err
| ) |  |
| inline

Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.

Entry is cleared only if it is not currently locked, and is not participating in a transaction.

This method should only be used on the valid instance.

Parameters

  key | Key to clear.
  err | Error.

## ◆ ClearAll() [1/3]

template<typename K, typename V>

void ignite::cache::Cache< K, V >::ClearAll | ( | const std::set< K > & | keys | ) |
| inline

Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.

Entry is cleared only if it is not currently locked, and is not participating in a transaction.

This method should only be used on the valid instance.

Parameters

  keys | Keys to clear.

## ◆ ClearAll() [2/3]

template<typename K, typename V>

void ignite::cache::Cache< K, V >::ClearAll | ( | const std::set< K > & | keys,
|  | IgniteError & | err
| ) |  |
| inline

Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.

Entry is cleared only if it is not currently locked, and is not participating in a transaction.

This method should only be used on the valid instance.

Parameters

  keys | Keys to clear.
  err | Error.

## ◆ ClearAll() [3/3]

template<typename K, typename V>
template<typename Iter >

void ignite::cache::Cache< K, V >::ClearAll | ( | Iter | begin,
|  | Iter | end
| ) |  |
| inline

Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.

Entry is cleared only if it is not currently locked, and is not participating in a transaction.

This method should only be used on the valid instance.

Parameters

  begin | Iterator pointing to the beggining of the key sequence.
  end | Iterator pointing to the end of the key sequence.

## ◆ ContainsKey() [1/2]

template<typename K, typename V>

bool ignite::cache::Cache< K, V >::ContainsKey | ( | const K & | key | ) |
| inline

Check if cache contains mapping for this key.

This method should only be used on the valid instance.

Parameters

  key | Key.

Returns
  True if cache contains mapping for this key.

## ◆ ContainsKey() [2/2]

template<typename K, typename V>

bool ignite::cache::Cache< K, V >::ContainsKey | ( | const K & | key,
|  | IgniteError & | err
| ) |  |
| inline

Check if cache contains mapping for this key.

This method should only be used on the valid instance.

Parameters

  key | Key.
  err | Error.

Returns
  True if cache contains mapping for this key.

## ◆ ContainsKeys() [1/3]

template<typename K, typename V>

bool ignite::cache::Cache< K, V >::ContainsKeys | ( | const std::set< K > & | keys | ) |
| inline

Check if cache contains mapping for these keys.

This method should only be used on the valid instance.

Parameters

  keys | Keys.

Returns
  True if cache contains mapping for all these keys.

## ◆ ContainsKeys() [2/3]

template<typename K, typename V>
template<typename InputIter >

bool ignite::cache::Cache< K, V >::ContainsKeys | ( | InputIter | begin,
|  | InputIter | end
| ) |  |
| inline

Check if cache contains mapping for these keys.

This method should only be used on the valid instance.

Parameters

  begin | Iterator pointing to the beggining of the key sequence.
  end | Iterator pointing to the end of the key sequence.

Returns
  True if cache contains mapping for all these keys.

## ◆ ContainsKeys() [3/3]

template<typename K, typename V>

bool ignite::cache::Cache< K, V >::ContainsKeys | ( | const std::set< K > & | keys,
|  | IgniteError & | err
| ) |  |
| inline

Check if cache contains mapping for these keys.

This method should only be used on the valid instance.

Parameters

  keys | Keys.
  err | Error.

Returns
  True if cache contains mapping for all these keys.

## ◆ Get() [1/2]

template<typename K, typename V>

V ignite::cache::Cache< K, V >::Get | ( | const K & | key | ) |
| inline

Retrieves value mapped to the specified key from cache.

If the value is not present in cache, then it will be looked up from swap storage. If it's not present in swap, or if swap is disabled, and if read-through is allowed, value will be loaded from persistent store. This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

Parameters

  key | Key.

Returns
  Value.

## ◆ Get() [2/2]

template<typename K, typename V>

V ignite::cache::Cache< K, V >::Get | ( | const K & | key,
|  | IgniteError & | err
| ) |  |
| inline

Retrieves value mapped to the specified key from cache.

If the value is not present in cache, then it will be looked up from swap storage. If it's not present in swap, or if swap is disabled, and if read-through is allowed, value will be loaded from persistent store. This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

Parameters

  key | Key.
  err | Error.

Returns
  Value.

## ◆ GetAll() [1/3]

template<typename K, typename V>

std::map<K, V> ignite::cache::Cache< K, V >::GetAll | ( | const std::set< K > & | keys | ) |
| inline

Retrieves values mapped to the specified keys from cache.

If some value is not present in cache, then it will be looked up from swap storage. If it's not present in swap, or if swap is disabled, and if read-through is allowed, value will be loaded from persistent store. This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

Parameters

  keys | Keys.

Returns
  Map of key-value pairs.

## ◆ GetAll() [2/3]

template<typename K, typename V>

std::map<K, V> ignite::cache::Cache< K, V >::GetAll | ( | const std::set< K > & | keys,
|  | IgniteError & | err
| ) |  |
| inline

Retrieves values mapped to the specified keys from cache.

If some value is not present in cache, then it will be looked up from swap storage. If it's not present in swap, or if swap is disabled, and if read-through is allowed, value will be loaded from persistent store. This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

Parameters

  keys | Keys.
  err | Error.

Returns
  Map of key-value pairs.

## ◆ GetAll() [3/3]

template<typename K, typename V>
template<typename InIter , typename OutIter >

void ignite::cache::Cache< K, V >::GetAll | ( | InIter | begin,
|  | InIter | end,
|  | OutIter | dst
| ) |  |
| inline

Retrieves values mapped to the specified keys from cache.

If some value is not present in cache, then it will be looked up from swap storage. If it's not present in swap, or if swap is disabled, and if read-through is allowed, value will be loaded from persistent store. This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

Parameters

  begin | Iterator pointing to the beggining of the key sequence.
  end | Iterator pointing to the end of the key sequence.
  dst | Output iterator. Should dereference to std::pair or CacheEntry.

## ◆ GetAndPut() [1/2]

template<typename K, typename V>

V ignite::cache::Cache< K, V >::GetAndPut | ( | const K & | key,
|  | const V & | val
| ) |  |
| inline

Associates the specified value with the specified key in this cache, returning an existing value if one existed.

This method should only be used on the valid instance.

Parameters

  key | Key with which the specified value is to be associated.
  val | Value to be associated with the specified key.

Returns
  The value associated with the key at the start of the operation or null if none was associated.

## ◆ GetAndPut() [2/2]

template<typename K, typename V>

V ignite::cache::Cache< K, V >::GetAndPut | ( | const K & | key,
|  | const V & | val,
|  | IgniteError & | err
| ) |  |
| inline

Associates the specified value with the specified key in this cache, returning an existing value if one existed.

This method should only be used on the valid instance.

Parameters

  key | Key with which the specified value is to be associated.
  val | Value to be associated with the specified key.
  err | Error.

Returns
  The value associated with the key at the start of the operation or null if none was associated.

## ◆ GetAndPutIfAbsent() [1/2]

template<typename K, typename V>

V ignite::cache::Cache< K, V >::GetAndPutIfAbsent | ( | const K & | key,
|  | const V & | val
| ) |  |
| inline

Stores given key-value pair in cache only if cache had no previous mapping for it.

If cache previously contained value for the given key, then this value is returned. In case of PARTITIONED or REPLICATED caches, the value will be loaded from the primary node, which in its turn may load the value from the swap storage, and consecutively, if it's not in swap, from the underlying persistent storage. If the returned value is not needed, method putxIfAbsent() should be used instead of this one to avoid the overhead associated with returning of the previous value. If write-through is enabled, the stored value will be persisted to store. This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

Parameters

  key | Key to store in cache.
  val | Value to be associated with the given key.

Returns
  Previously contained value regardless of whether put happened or not (null if there was no previous value).

## ◆ GetAndPutIfAbsent() [2/2]

template<typename K, typename V>

V ignite::cache::Cache< K, V >::GetAndPutIfAbsent | ( | const K & | key,
|  | const V & | val,
|  | IgniteError & | err
| ) |  |
| inline

Stores given key-value pair in cache only if cache had no previous mapping for it.

If cache previously contained value for the given key, then this value is returned. In case of PARTITIONED or REPLICATED caches, the value will be loaded from the primary node, which in its turn may load the value from the swap storage, and consecutively, if it's not in swap, from the underlying persistent storage. If the returned value is not needed, method putxIfAbsent() should be used instead of this one to avoid the overhead associated with returning of the previous value. If write-through is enabled, the stored value will be persisted to store. This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

Parameters

  key | Key to store in cache.
  val | Value to be associated with the given key.
  err | Error.

Returns
  Previously contained value regardless of whether put happened or not (null if there was no previous value).

## ◆ GetAndRemove() [1/2]

template<typename K, typename V>

V ignite::cache::Cache< K, V >::GetAndRemove | ( | const K & | key | ) |
| inline

Atomically removes the entry for a key only if currently mapped to some value.

This method should only be used on the valid instance.

Parameters

  key | Key with which the specified value is associated.

Returns
  The value if one existed or null if no mapping existed for this key.

## ◆ GetAndRemove() [2/2]

template<typename K, typename V>

V ignite::cache::Cache< K, V >::GetAndRemove | ( | const K & | key,
|  | IgniteError & | err
| ) |  |
| inline

Atomically removes the entry for a key only if currently mapped to some value.

This method should only be used on the valid instance.

Parameters

  key | Key with which the specified value is associated.
  err | Error.

Returns
  The value if one existed or null if no mapping existed for this key.

## ◆ GetAndReplace() [1/2]

template<typename K, typename V>

V ignite::cache::Cache< K, V >::GetAndReplace | ( | const K & | key,
|  | const V & | val
| ) |  |
| inline

Atomically replaces the value for a given key if and only if there is a value currently mapped by the key.

This method should only be used on the valid instance.

Parameters

  key | Key with which the specified value is to be associated.
  val | Value to be associated with the specified key.

Returns
  The previous value associated with the specified key, or null if there was no mapping for the key.

## ◆ GetAndReplace() [2/2]

template<typename K, typename V>

V ignite::cache::Cache< K, V >::GetAndReplace | ( | const K & | key,
|  | const V & | val,
|  | IgniteError & | err
| ) |  |
| inline

Atomically replaces the value for a given key if and only if there is a value currently mapped by the key.

This method should only be used on the valid instance.

Parameters

  key | Key with which the specified value is to be associated.
  val | Value to be associated with the specified key.
  err | Error.

Returns
  The previous value associated with the specified key, or null if there was no mapping for the key.

## ◆ GetName()

template<typename K, typename V>

const char* ignite::cache::Cache< K, V >::GetName | ( |  | ) | const
| inline

Get name of this cache (null for default cache).

This method should only be used on the valid instance.

Returns
  Name of this cache (null for default cache).

## ◆ Invoke() [1/2]

template<typename K, typename V>
template<typename R , typename P , typename A >

R ignite::cache::Cache< K, V >::Invoke | ( | const K & | key,
|  | const P & | processor,
|  | const A & | arg
| ) |  |
| inline

Invokes an CacheEntryProcessor against the MutableCacheEntry specified by the provided key.

If an entry does not exist for the specified key, an attempt is made to load it (if a loader is configured) or a surrogate entry, consisting of the key with a null value is used instead.

Return value, processor and argument classes should all be default-constructable, copy-constructable and assignable. Also, BinaryType class template should be specialized for every custom class.

Processor class should be registered as a cache entry processor using IgniteBinding::RegisterCacheEntryProcessor() method. You can declare #IgniteModuleInit() function to register your cache processors upon module loading. There should be at most one instance of such function per module.

See the example below for details:

IGNITE_EXPORTED_CALL void IgniteModuleInit(ignite::IgniteBindingContext& context)
{
IgniteBinding binding = context.GetBinding();
binding.RegisterCacheEntryProcessor<MyProcessor1>();
binding.RegisterCacheEntryProcessor<MyProcessor2>();
// ...
binding.RegisterCacheEntryProcessor<MyProcessorN>();
}

Additionally, processor class should be derived from the ignite::CacheEntryProcessor class.

Exceptions

  IgniteError | on fail.

Parameters

  key | The key.
  processor | The processor.
  arg | The argument.

Returns
  Result of the processing.

## ◆ Invoke() [2/2]

template<typename K, typename V>
template<typename R , typename P , typename A >

R ignite::cache::Cache< K, V >::Invoke | ( | const K & | key,
|  | const P & | processor,
|  | const A & | arg,
|  | IgniteError & | err
| ) |  |
| inline

Invokes an CacheEntryProcessor against the MutableCacheEntry specified by the provided key.

If an entry does not exist for the specified key, an attempt is made to load it (if a loader is configured) or a surrogate entry, consisting of the key with a null value is used instead.

Return value, processor and argument classes should all be default-constructable, copy-constructable and assignable. Also, BinaryType class template should be specialized for every custom class.

Processor class should be registered as a cache entry processor using IgniteBinding::RegisterCacheEntryProcessor() method. You can declare #IgniteModuleInit() function to register your cache processors upon module loading. There should be at most one instance of such function per module.

See the example below for details:

IGNITE_EXPORTED_CALL void IgniteModuleInit(ignite::IgniteBindingContext& context)
{
IgniteBinding binding = context.GetBinding();
binding.RegisterCacheEntryProcessor<MyProcessor1>();
binding.RegisterCacheEntryProcessor<MyProcessor2>();
// ...
binding.RegisterCacheEntryProcessor<MyProcessorN>();
}

Additionally, processor class should be derived from the ignite::CacheEntryProcessor class.

Sets err param which should be checked for the operation result.

Parameters

  key | The key.
  processor | The processor.
  arg | The argument.
  err | Error.

Returns
  Result of the processing. Default-constructed value on error.

## ◆ IsEmpty() [1/2]

template<typename K, typename V>

bool ignite::cache::Cache< K, V >::IsEmpty | ( |  | ) |
| inline

Checks whether this cache contains no key-value mappings.

Semantically equals to Cache.Size(CachePeekMode::PRIMARY) == 0.

This method should only be used on the valid instance.

Returns
  True if cache is empty.

## ◆ IsEmpty() [2/2]

template<typename K, typename V>

bool ignite::cache::Cache< K, V >::IsEmpty | ( | IgniteError & | err | ) |
| inline

Checks whether this cache contains no key-value mappings.

Semantically equals to Cache.Size(CachePeekMode::PRIMARY) == 0.

This method should only be used on the valid instance.

Parameters

  err | Error.

Returns
  True if cache is empty.

## ◆ IsValid()

template<typename K, typename V>

bool ignite::cache::Cache< K, V >::IsValid | ( |  | ) | const
| inline

Check if the instance is valid.

Invalid instance can be returned if some of the previous operations have resulted in a failure. For example invalid instance can be returned by not-throwing version of method in case of error. Invalid instances also often can be created using default constructor.

Returns
  True if the instance is valid and can be used.

## ◆ LocalClear() [1/2]

template<typename K, typename V>

void ignite::cache::Cache< K, V >::LocalClear | ( | const K & | key | ) |
| inline

Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.

Entry is cleared only if it is not currently locked, and is not participating in a transaction.

Note
  This operation is local as it merely clears an entry from local cache, it does not remove entries from remote caches.

This method should only be used on the valid instance.

Parameters

  key | Key to clear.

## ◆ LocalClear() [2/2]

template<typename K, typename V>

void ignite::cache::Cache< K, V >::LocalClear | ( | const K & | key,
|  | IgniteError & | err
| ) |  |
| inline

Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.

Entry is cleared only if it is not currently locked, and is not participating in a transaction.

Note
  This operation is local as it merely clears an entry from local cache, it does not remove entries from remote caches.

This method should only be used on the valid instance.

Parameters

  key | Key to clear.
  err | Error.

## ◆ LocalClearAll() [1/3]

template<typename K, typename V>

void ignite::cache::Cache< K, V >::LocalClearAll | ( | const std::set< K > & | keys | ) |
| inline

Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.

Entry is cleared only if it is not currently locked, and is not participating in a transaction.

Note
  This operation is local as it merely clears entries from local cache, it does not remove entries from remote caches.

This method should only be used on the valid instance.

Parameters

  keys | Keys to clear.

## ◆ LocalClearAll() [2/3]

template<typename K, typename V>

void ignite::cache::Cache< K, V >::LocalClearAll | ( | const std::set< K > & | keys,
|  | IgniteError & | err
| ) |  |
| inline

Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.

Entry is cleared only if it is not currently locked, and is not participating in a transaction.

Note
  This operation is local as it merely clears entries from local cache, it does not remove entries from remote caches.

This method should only be used on the valid instance.

Parameters

  keys | Keys to clear.
  err | Error.

## ◆ LocalClearAll() [3/3]

template<typename K, typename V>
template<typename Iter >

void ignite::cache::Cache< K, V >::LocalClearAll | ( | Iter | begin,
|  | Iter | end
| ) |  |
| inline

Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.

Entry is cleared only if it is not currently locked, and is not participating in a transaction.

Note
  This operation is local as it merely clears entries from local cache, it does not remove entries from remote caches.

This method should only be used on the valid instance.

Parameters

  begin | Iterator pointing to the beggining of the key sequence.
  end | Iterator pointing to the end of the key sequence.

## ◆ LocalEvict() [1/3]

template<typename K, typename V>

void ignite::cache::Cache< K, V >::LocalEvict | ( | const std::set< K > & | keys | ) |
| inline

Attempts to evict all entries associated with keys.

Note
  Entry will be evicted only if it's not used (not participating in any locks or transactions).

This method should only be used on the valid instance.

Parameters

  keys | Keys to evict from cache.

## ◆ LocalEvict() [2/3]

template<typename K, typename V>

void ignite::cache::Cache< K, V >::LocalEvict | ( | const std::set< K > & | keys,
|  | IgniteError & | err
| ) |  |
| inline

Attempts to evict all entries associated with keys.

Note
  Entry will be evicted only if it's not used (not participating in any locks or transactions).

This method should only be used on the valid instance.

Parameters

  keys | Keys to evict from cache.
  err | Error.

## ◆ LocalEvict() [3/3]

template<typename K, typename V>
template<typename Iter >

void ignite::cache::Cache< K, V >::LocalEvict | ( | Iter | begin,
|  | Iter | end
| ) |  |
| inline

Attempts to evict all entries associated with keys.

Note
  Entry will be evicted only if it's not used (not participating in any locks or transactions).

This method should only be used on the valid instance.

Parameters

  begin | Iterator pointing to the beggining of the key sequence.
  end | Iterator pointing to the end of the key sequence.

## ◆ LocalLoadCache()

template<typename K, typename V>

void ignite::cache::Cache< K, V >::LocalLoadCache | ( |  | ) |
| inline

Loads state from the underlying persistent storage.

This method is not transactional and may end up loading a stale value into cache if another thread has updated the value immediately after it has been loaded. It is mostly useful when pre-loading the cache from underlying data store before start, or for read-only caches.

## ◆ LocalPeek() [1/2]

template<typename K, typename V>

V ignite::cache::Cache< K, V >::LocalPeek | ( | const K & | key,
|  | int32_t | peekModes
| ) |  |
| inline

Peeks at cached value using optional set of peek modes.

This method will sequentially iterate over given peek modes, and try to peek at value using each peek mode. Once a non-null value is found, it will be immediately returned. This method does not participate in any transactions, however, it may peek at transactional value depending on the peek modes used.

This method should only be used on the valid instance.

Parameters

  key | Key.
  peekModes | Peek modes.

Returns
  Value.

## ◆ LocalPeek() [2/2]

template<typename K, typename V>

V ignite::cache::Cache< K, V >::LocalPeek | ( | const K & | key,
|  | int32_t | peekModes,
|  | IgniteError & | err
| ) |  |
| inline

Peeks at cached value using optional set of peek modes.

This method will sequentially iterate over given peek modes, and try to peek at value using each peek mode. Once a non-null value is found, it will be immediately returned. This method does not participate in any transactions, however, it may peek at transactional value depending on the peek modes used.

This method should only be used on the valid instance.

Parameters

  key | Key.
  peekModes | Peek modes.
  err | Error.

Returns
  Value.

## ◆ LocalSize() [1/4]

template<typename K, typename V>

int32_t ignite::cache::Cache< K, V >::LocalSize | ( |  | ) |
| inline

Gets the number of all entries cached on this node.

This method should only be used on the valid instance.

Returns
  Cache size on this node.

## ◆ LocalSize() [2/4]

template<typename K, typename V>

int32_t ignite::cache::Cache< K, V >::LocalSize | ( | IgniteError & | err | ) |
| inline

Gets the number of all entries cached on this node.

This method should only be used on the valid instance.

Parameters

  err | Error.

Returns
  Cache size on this node.

## ◆ LocalSize() [3/4]

template<typename K, typename V>

int32_t ignite::cache::Cache< K, V >::LocalSize | ( | int32_t | peekModes | ) |
| inline

Gets the number of all entries cached on this node.

This method should only be used on the valid instance.

Parameters

  peekModes | Peek modes.

Returns
  Cache size on this node.

## ◆ LocalSize() [4/4]

template<typename K, typename V>

int32_t ignite::cache::Cache< K, V >::LocalSize | ( | int32_t | peekModes,
|  | IgniteError & | err
| ) |  |
| inline

Gets the number of all entries cached on this node.

This method should only be used on the valid instance.

Parameters

  peekModes | Peek modes.
  err | Error.

Returns
  Cache size on this node.

## ◆ Put() [1/2]

template<typename K, typename V>

void ignite::cache::Cache< K, V >::Put | ( | const K & | key,
|  | const V & | val
| ) |  |
| inline

Associates the specified value with the specified key in the cache.

If the cache previously contained a mapping for the key, the old value is replaced by the specified value.

This method should only be used on the valid instance.

Parameters

  key | Key with which the specified value is to be associated.
  val | Value to be associated with the specified key.

## ◆ Put() [2/2]

template<typename K, typename V>

void ignite::cache::Cache< K, V >::Put | ( | const K & | key,
|  | const V & | val,
|  | IgniteError & | err
| ) |  |
| inline

Associates the specified value with the specified key in the cache.

If the cache previously contained a mapping for the key, the old value is replaced by the specified value.

This method should only be used on the valid instance.

Parameters

  key | Key with which the specified value is to be associated.
  val | Value to be associated with the specified key.
  err | Error.

## ◆ PutAll() [1/3]

template<typename K, typename V>

void ignite::cache::Cache< K, V >::PutAll | ( | const std::map< K, V > & | vals | ) |
| inline

Stores given key-value pairs in cache.

If write-through is enabled, the stored values will be persisted to store. This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

Parameters

  vals | Key-value pairs to store in cache.

## ◆ PutAll() [2/3]

template<typename K, typename V>

void ignite::cache::Cache< K, V >::PutAll | ( | const std::map< K, V > & | vals,
|  | IgniteError & | err
| ) |  |
| inline

Stores given key-value pairs in cache.

If write-through is enabled, the stored values will be persisted to store. This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

Parameters

  vals | Key-value pairs to store in cache.
  err | Error.

## ◆ PutAll() [3/3]

template<typename K, typename V>
template<typename Iter >

void ignite::cache::Cache< K, V >::PutAll | ( | Iter | begin,
|  | Iter | end
| ) |  |
| inline

Stores given key-value pairs in cache.

If write-through is enabled, the stored values will be persisted to store. This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

Keys are locked in the order of iteration. It is caller's responsibility to make sure keys always follow same order. If that is not observed, calling this method in parallel will lead to deadlock.

Parameters

  begin | Iterator pointing to the beggining of the key-value pair sequence.
  end | Iterator pointing to the end of the key-value pair sequence.

## ◆ PutIfAbsent() [1/2]

template<typename K, typename V>

bool ignite::cache::Cache< K, V >::PutIfAbsent | ( | const K & | key,
|  | const V & | val
| ) |  |
| inline

Atomically associates the specified key with the given value if it is not already associated with a value.

This method should only be used on the valid instance.

Parameters

  key | Key with which the specified value is to be associated.
  val | Value to be associated with the specified key.

Returns
  True if a value was set.

## ◆ PutIfAbsent() [2/2]

template<typename K, typename V>

bool ignite::cache::Cache< K, V >::PutIfAbsent | ( | const K & | key,
|  | const V & | val,
|  | IgniteError & | err
| ) |  |
| inline

Atomically associates the specified key with the given value if it is not already associated with a value.

This method should only be used on the valid instance.

Parameters

  key | Key with which the specified value is to be associated.
  val | Value to be associated with the specified key.
  err | Error.

Returns
  True if a value was set.

## ◆ Query() [1/8]

template<typename K, typename V>

query::QueryCursor<K, V> ignite::cache::Cache< K, V >::Query | ( | const query::SqlQuery & | qry | ) |
| inline

Perform SQL query.

Deprecated:
  Will be removed in future releases. Use SqlFieldsQuery instead.

This method should only be used on the valid instance.

Parameters

  qry | Query.

Returns
  Query cursor.

## ◆ Query() [2/8]

template<typename K, typename V>

query::QueryCursor<K, V> ignite::cache::Cache< K, V >::Query | ( | const query::SqlQuery & | qry,
|  | IgniteError & | err
| ) |  |
| inline

Perform SQL query.

This method should only be used on the valid instance.

Parameters

  qry | Query.
  err | Error.

Returns
  Query cursor.

## ◆ Query() [3/8]

template<typename K, typename V>

query::QueryCursor<K, V> ignite::cache::Cache< K, V >::Query | ( | const query::TextQuery & | qry | ) |
| inline

Perform text query.

This method should only be used on the valid instance.

Parameters

  qry | Query.

Returns
  Query cursor.

## ◆ Query() [4/8]

template<typename K, typename V>

query::QueryCursor<K, V> ignite::cache::Cache< K, V >::Query | ( | const query::TextQuery & | qry,
|  | IgniteError & | err
| ) |  |
| inline

Perform text query.

This method should only be used on the valid instance.

Parameters

  qry | Query.
  err | Error.

Returns
  Query cursor.

## ◆ Query() [5/8]

template<typename K, typename V>

query::QueryCursor<K, V> ignite::cache::Cache< K, V >::Query | ( | const query::ScanQuery & | qry | ) |
| inline

Perform scan query.

This method should only be used on the valid instance.

Parameters

  qry | Query.

Returns
  Query cursor.

## ◆ Query() [6/8]

template<typename K, typename V>

query::QueryCursor<K, V> ignite::cache::Cache< K, V >::Query | ( | const query::ScanQuery & | qry,
|  | IgniteError & | err
| ) |  |
| inline

Perform scan query.

This method should only be used on the valid instance.

Parameters

  qry | Query.
  err | Error.

Returns
  Query cursor.

## ◆ Query() [7/8]

template<typename K, typename V>

query::QueryFieldsCursor ignite::cache::Cache< K, V >::Query | ( | const query::SqlFieldsQuery & | qry | ) |
| inline

Perform sql fields query.

This method should only be used on the valid instance.

Parameters

  qry | Query.

Returns
  Query cursor.

## ◆ Query() [8/8]

template<typename K, typename V>

query::QueryFieldsCursor ignite::cache::Cache< K, V >::Query | ( | const query::SqlFieldsQuery & | qry,
|  | IgniteError & | err
| ) |  |
| inline

Perform sql fields query.

This method should only be used on the valid instance.

Parameters

  qry | Query.
  err | Error.

Returns
  Query cursor.

## ◆ QueryContinuous() [1/4]

template<typename K, typename V>

query::continuous::ContinuousQueryHandle<K, V> ignite::cache::Cache< K, V >::QueryContinuous | ( | const query::continuous::ContinuousQuery< K, V > & | qry | ) |
| inline

Start continuous query execution.

Parameters

  qry | Continuous query.

Returns
  Continuous query handle.

## ◆ QueryContinuous() [2/4]

template<typename K, typename V>

query::continuous::ContinuousQueryHandle<K, V> ignite::cache::Cache< K, V >::QueryContinuous | ( | const query::continuous::ContinuousQuery< K, V > & | qry,
|  | IgniteError & | err
| ) |  |
| inline

Start continuous query execution.

Parameters

  qry | Continuous query.
  err | Error.

Returns
  Continuous query handle.

## ◆ QueryContinuous() [3/4]

template<typename K, typename V>
template<typename Q >

query::continuous::ContinuousQueryHandle<K, V> ignite::cache::Cache< K, V >::QueryContinuous | ( | const query::continuous::ContinuousQuery< K, V > & | qry,
|  | const Q & | initialQry
| ) |  |
| inline

Start continuous query execution with the initial query.

Parameters

  qry | Continuous query.
  initialQry | Initial query to be executed.

Returns
  Continuous query handle.

## ◆ QueryContinuous() [4/4]

template<typename K, typename V>
template<typename Q >

query::continuous::ContinuousQueryHandle<K, V> ignite::cache::Cache< K, V >::QueryContinuous | ( | const query::continuous::ContinuousQuery< K, V > & | qry,
|  | const Q & | initialQry,
|  | IgniteError & | err
| ) |  |
| inline

Start continuous query execution with the initial query.

Parameters

  qry | Continuous query.
  initialQry | Initial query to be executed.
  err | Error.

Returns
  Continuous query handle.

## ◆ Remove() [1/4]

template<typename K, typename V>

bool ignite::cache::Cache< K, V >::Remove | ( | const K & | key | ) |
| inline

Removes given key mapping from cache.

If cache previously contained value for the given key, then this value is returned. In case of PARTITIONED or REPLICATED caches, the value will be loaded from the primary node, which in its turn may load the value from the disk-based swap storage, and consecutively, if it's not in swap, from the underlying persistent storage. If the returned value is not needed, method removex() should always be used instead of this one to avoid the overhead associated with returning of the previous value. If write-through is enabled, the value will be removed from store. This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

Parameters

  key | Key whose mapping is to be removed from cache.

Returns
  False if there was no matching key.

## ◆ Remove() [2/4]

template<typename K, typename V>

bool ignite::cache::Cache< K, V >::Remove | ( | const K & | key,
|  | IgniteError & | err
| ) |  |
| inline

Removes given key mapping from cache.

If cache previously contained value for the given key, then this value is returned. In case of PARTITIONED or REPLICATED caches, the value will be loaded from the primary node, which in its turn may load the value from the disk-based swap storage, and consecutively, if it's not in swap, from the underlying persistent storage. If the returned value is not needed, method removex() should always be used instead of this one to avoid the overhead associated with returning of the previous value. If write-through is enabled, the value will be removed from store. This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

Parameters

  key | Key whose mapping is to be removed from cache.
  err | Error.

Returns
  False if there was no matching key.

## ◆ Remove() [3/4]

template<typename K, typename V>

bool ignite::cache::Cache< K, V >::Remove | ( | const K & | key,
|  | const V & | val
| ) |  |
| inline

Removes given key mapping from cache if one exists and value is equal to the passed in value.

If write-through is enabled, the value will be removed from store. This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

Parameters

  key | Key whose mapping is to be removed from cache.
  val | Value to match against currently cached value.

Returns
  True if entry was removed, false otherwise.

## ◆ Remove() [4/4]

template<typename K, typename V>

bool ignite::cache::Cache< K, V >::Remove | ( | const K & | key,
|  | const V & | val,
|  | IgniteError & | err
| ) |  |
| inline

Removes given key mapping from cache if one exists and value is equal to the passed in value.

If write-through is enabled, the value will be removed from store. This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

Parameters

  key | Key whose mapping is to be removed from cache.
  val | Value to match against currently cached value.
  err | Error.

Returns
  True if entry was removed, false otherwise.

## ◆ RemoveAll() [1/5]

template<typename K, typename V>

void ignite::cache::Cache< K, V >::RemoveAll | ( | const std::set< K > & | keys | ) |
| inline

Removes given key mappings from cache.

If write-through is enabled, the value will be removed from store. This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

Parameters

  keys | Keys whose mappings are to be removed from cache.

## ◆ RemoveAll() [2/5]

template<typename K, typename V>

void ignite::cache::Cache< K, V >::RemoveAll | ( | const std::set< K > & | keys,
|  | IgniteError & | err
| ) |  |
| inline

Removes given key mappings from cache.

If write-through is enabled, the value will be removed from store. This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

Parameters

  keys | Keys whose mappings are to be removed from cache.
  err | Error.

## ◆ RemoveAll() [3/5]

template<typename K, typename V>
template<typename Iter >

void ignite::cache::Cache< K, V >::RemoveAll | ( | Iter | begin,
|  | Iter | end
| ) |  |
| inline

Removes given key mappings from cache.

If write-through is enabled, the value will be removed from store. This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

Keys are locked in the order of iteration. It is caller's responsibility to make sure keys always follow same order. If that is not observed, calling this method in parallel will lead to deadlock.

Parameters

  begin | Iterator pointing to the beggining of the key sequence.
  end | Iterator pointing to the end of the key sequence.

## ◆ RemoveAll() [4/5]

template<typename K, typename V>

void ignite::cache::Cache< K, V >::RemoveAll | ( |  | ) |
| inline

Removes all mappings from cache.

If write-through is enabled, the value will be removed from store. This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

## ◆ RemoveAll() [5/5]

template<typename K, typename V>

void ignite::cache::Cache< K, V >::RemoveAll | ( | IgniteError & | err | ) |
| inline

Removes all mappings from cache.

If write-through is enabled, the value will be removed from store. This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

Parameters

  err | Error.

## ◆ Replace() [1/4]

template<typename K, typename V>

bool ignite::cache::Cache< K, V >::Replace | ( | const K & | key,
|  | const V & | val
| ) |  |
| inline

Stores given key-value pair in cache only if there is a previous mapping for it.

If cache previously contained value for the given key, then this value is returned. In case of PARTITIONED or REPLICATED caches, the value will be loaded from the primary node, which in its turn may load the value from the swap storage, and consecutively, if it's not in swap, rom the underlying persistent storage. If write-through is enabled, the stored value will be persisted to store. This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

Parameters

  key | Key to store in cache.
  val | Value to be associated with the given key.

Returns
  True if the value was replaced.

## ◆ Replace() [2/4]

template<typename K, typename V>

bool ignite::cache::Cache< K, V >::Replace | ( | const K & | key,
|  | const V & | val,
|  | IgniteError & | err
| ) |  |
| inline

Stores given key-value pair in cache only if there is a previous mapping for it.

If cache previously contained value for the given key, then this value is returned. In case of PARTITIONED or REPLICATED caches, the value will be loaded from the primary node, which in its turn may load the value from the swap storage, and consecutively, if it's not in swap, rom the underlying persistent storage. If write-through is enabled, the stored value will be persisted to store. This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

Parameters

  key | Key to store in cache.
  val | Value to be associated with the given key.
  err | Error.

Returns
  True if the value was replaced.

## ◆ Replace() [3/4]

template<typename K, typename V>

bool ignite::cache::Cache< K, V >::Replace | ( | const K & | key,
|  | const V & | oldVal,
|  | const V & | newVal
| ) |  |
| inline

Stores given key-value pair in cache only if the previous value is equal to the old value passed as argument.

This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

Parameters

  key | Key to store in cache.
  oldVal | Old value to match.
  newVal | Value to be associated with the given key.

Returns
  True if replace happened, false otherwise.

## ◆ Replace() [4/4]

template<typename K, typename V>

bool ignite::cache::Cache< K, V >::Replace | ( | const K & | key,
|  | const V & | oldVal,
|  | const V & | newVal,
|  | IgniteError & | err
| ) |  |
| inline

Stores given key-value pair in cache only if the previous value is equal to the old value passed as argument.

This method is transactional and will enlist the entry into ongoing transaction if there is one.

This method should only be used on the valid instance.

Parameters

  key | Key to store in cache.
  oldVal | Old value to match.
  newVal | Value to be associated with the given key.
  err | Error.

Returns
  True if replace happened, false otherwise.

## ◆ Size() [1/4]

template<typename K, typename V>

int32_t ignite::cache::Cache< K, V >::Size | ( |  | ) |
| inline

Gets the number of all entries cached across all nodes.

Note
  this operation is distributed and will query all participating nodes for their cache sizes.

This method should only be used on the valid instance.

Returns
  Cache size across all nodes.

## ◆ Size() [2/4]

template<typename K, typename V>

int32_t ignite::cache::Cache< K, V >::Size | ( | IgniteError & | err | ) |
| inline

Gets the number of all entries cached across all nodes.

Note
  This operation is distributed and will query all participating nodes for their cache sizes.

This method should only be used on the valid instance.

Parameters

  err | Error.

Returns
  Cache size across all nodes.

## ◆ Size() [3/4]

template<typename K, typename V>

int32_t ignite::cache::Cache< K, V >::Size | ( | int32_t | peekModes | ) |
| inline

Gets the number of all entries cached across all nodes.

Note
  This operation is distributed and will query all participating nodes for their cache sizes.

This method should only be used on the valid instance.

Parameters

  peekModes | Peek modes.

Returns
  Cache size across all nodes.

## ◆ Size() [4/4]

template<typename K, typename V>

int32_t ignite::cache::Cache< K, V >::Size | ( | int32_t | peekModes,
|  | IgniteError & | err
| ) |  |
| inline

Gets the number of all entries cached across all nodes.

Note
  This operation is distributed and will query all participating nodes for their cache sizes.

This method should only be used on the valid instance.

Parameters

  peekModes | Peek modes.
  err | Error.

Returns
  Cache size across all nodes.

The documentation for this class was generated from the following file:

- cache.h