Apache Ignite C++
Public Types | Public Member Functions | Friends | List of all members
ignite::thin::cache::CacheClient< K, V > Class Template Reference

Cache client class template. More...

#include <cache_client.h>

Public Types

typedef K KeyType
 Key type. More...
 
typedef V ValueType
 Value type. More...
 

Public Member Functions

 CacheClient (common::concurrent::SharedPointer< void > impl)
 Constructor. More...
 
 CacheClient ()
 Default constructor.
 
 ~CacheClient ()
 Destructor.
 
void Put (const KeyType &key, const ValueType &value)
 Associate the specified value with the specified key in the cache. More...
 
template<typename InIter >
void PutAll (InIter begin, InIter end)
 Stores given key-value pairs in cache. More...
 
template<typename Map >
void PutAll (const Map &vals)
 Stores given key-value pairs in cache. More...
 
void Get (const KeyType &key, ValueType &value)
 Get value from the cache. More...
 
ValueType Get (const KeyType &key)
 Get value 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...
 
template<typename Set , typename Map >
void GetAll (const Set &keys, Map &res)
 Retrieves values mapped to the specified keys from cache. More...
 
bool Replace (const K &key, const V &value)
 Stores given key-value pair in cache only if there is a previous mapping for it. More...
 
bool ContainsKey (const KeyType &key)
 Check if the cache contains a value for the specified key. More...
 
template<typename Set >
bool ContainsKeys (const Set &keys)
 Check if cache contains mapping for these keys. More...
 
template<typename InIter >
bool ContainsKeys (InIter begin, InIter end)
 Check if cache contains mapping for these keys. More...
 
int64_t GetSize (int32_t peekModes)
 Gets the number of all entries cached across all nodes. More...
 
bool Remove (const KeyType &key)
 Removes given key mapping from cache. More...
 
template<typename Set >
void RemoveAll (const Set &keys)
 Removes given key mappings from cache. More...
 
template<typename InIter >
void RemoveAll (InIter begin, InIter end)
 Removes given key mappings from cache. More...
 
void RemoveAll ()
 Removes all mappings from cache. More...
 
void Clear (const KeyType &key)
 Clear entry from the cache and swap storage, without notifying listeners or CacheWriters. More...
 
void Clear ()
 Clear cache.
 
template<typename Set >
void ClearAll (const Set &keys)
 Clear entries from the cache and swap storage, without notifying listeners or CacheWriters. More...
 
template<typename InIter >
void ClearAll (InIter begin, InIter end)
 Clear entries from the cache and swap storage, without notifying listeners or CacheWriters. More...
 
void RefreshAffinityMapping ()
 Refresh affinity mapping. More...
 

Friends

class impl::thin::cache::CacheClientProxy
 

Detailed Description

template<typename K, typename V>
class ignite::thin::cache::CacheClient< K, V >

Cache client class template.

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, if they are not one of the basic types.

This class 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 released automatically once all the instances are destructed.

Template Parameters
KCache key type.
VCache value type.

Member Typedef Documentation

template<typename K, typename V>
typedef K ignite::thin::cache::CacheClient< K, V >::KeyType

Key type.

template<typename K, typename V>
typedef V ignite::thin::cache::CacheClient< K, V >::ValueType

Value type.

Constructor & Destructor Documentation

template<typename K, typename V>
ignite::thin::cache::CacheClient< K, V >::CacheClient ( common::concurrent::SharedPointer< void >  impl)
inline

Constructor.

Parameters
implImplementation.

Member Function Documentation

template<typename K, typename V>
void ignite::thin::cache::CacheClient< K, V >::Clear ( const KeyType 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.

Parameters
keyKey to clear.
template<typename K, typename V>
template<typename Set >
void ignite::thin::cache::CacheClient< K, V >::ClearAll ( const Set &  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.

Parameters
keysKeys to clear.
template<typename K, typename V>
template<typename InIter >
void ignite::thin::cache::CacheClient< K, V >::ClearAll ( InIter  begin,
InIter  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.

Parameters
beginIterator pointing to the beginning of the key sequence.
endIterator pointing to the end of the key sequence.
template<typename K, typename V>
bool ignite::thin::cache::CacheClient< K, V >::ContainsKey ( const KeyType key)
inline

Check if the cache contains a value for the specified key.

Parameters
keyKey whose presence in this cache is to be tested.
Returns
true if the cache contains specified key.
template<typename K, typename V>
template<typename Set >
bool ignite::thin::cache::CacheClient< K, V >::ContainsKeys ( const Set &  keys)
inline

Check if cache contains mapping for these keys.

Parameters
keysKeys.
Returns
True if cache contains mapping for all these keys.
template<typename K, typename V>
template<typename InIter >
bool ignite::thin::cache::CacheClient< K, V >::ContainsKeys ( InIter  begin,
InIter  end 
)
inline

Check if cache contains mapping for these keys.

Parameters
beginIterator pointing to the beginning of the key sequence.
endIterator pointing to the end of the key sequence.
Returns
True if cache contains mapping for all these keys.
template<typename K, typename V>
void ignite::thin::cache::CacheClient< K, V >::Get ( const KeyType key,
ValueType value 
)
inline

Get value from the cache.

Parameters
keyKey.
valueValue.
template<typename K, typename V>
ValueType ignite::thin::cache::CacheClient< K, V >::Get ( const KeyType key)
inline

Get value from cache.

Parameters
keyKey.
Returns
Value.
template<typename K, typename V>
template<typename InIter , typename OutIter >
void ignite::thin::cache::CacheClient< 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.

Parameters
beginIterator pointing to the beginning of the key sequence.
endIterator pointing to the end of the key sequence.
dstOutput iterator. Should dereference to std::pair or CacheEntry.
template<typename K, typename V>
template<typename Set , typename Map >
void ignite::thin::cache::CacheClient< K, V >::GetAll ( const Set &  keys,
Map &  res 
)
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.

Parameters
keysKeys.
resMap of key-value pairs.
template<typename K, typename V>
int64_t ignite::thin::cache::CacheClient< K, V >::GetSize ( 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.
See also
CachePeekMode for details.
Parameters
peekModesPeek modes mask.
Returns
Cache size across all nodes.
template<typename K, typename V>
void ignite::thin::cache::CacheClient< K, V >::Put ( const KeyType key,
const ValueType value 
)
inline

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

Parameters
keyKey.
valueValue.
template<typename K, typename V>
template<typename InIter >
void ignite::thin::cache::CacheClient< K, V >::PutAll ( InIter  begin,
InIter  end 
)
inline

Stores given key-value pairs in cache.

If write-through is enabled, the stored values will be persisted to store.

Parameters
beginIterator pointing to the beginning of the key-value pair sequence.
endIterator pointing to the end of the key-value pair sequence.
template<typename K, typename V>
template<typename Map >
void ignite::thin::cache::CacheClient< K, V >::PutAll ( const Map &  vals)
inline

Stores given key-value pairs in cache.

If write-through is enabled, the stored values will be persisted to store.

Parameters
valsKey-value pairs to store in cache.
template<typename K, typename V>
void ignite::thin::cache::CacheClient< K, V >::RefreshAffinityMapping ( )
inline

Refresh affinity mapping.

Retrieves affinity mapping information from remote server. This information uses to send data requests to the most appropriate nodes. This can lessen latency and improve overall performance.

It is recommended to refresh affinity mapping after every topology change, i.e. when a node enters or leaves cluster.

template<typename K, typename V>
bool ignite::thin::cache::CacheClient< K, V >::Remove ( const KeyType 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.

Parameters
keyKey whose mapping is to be removed from cache.
Returns
False if there was no matching key.
template<typename K, typename V>
template<typename Set >
void ignite::thin::cache::CacheClient< K, V >::RemoveAll ( const Set &  keys)
inline

Removes given key mappings from cache.

If write-through is enabled, the value will be removed from store.

Parameters
keysKeys whose mappings are to be removed from cache.
template<typename K, typename V>
template<typename InIter >
void ignite::thin::cache::CacheClient< K, V >::RemoveAll ( InIter  begin,
InIter  end 
)
inline

Removes given key mappings from cache.

If write-through is enabled, the value will be removed from store.

Parameters
beginIterator pointing to the beginning of the key sequence.
endIterator pointing to the end of the key sequence.
template<typename K, typename V>
void ignite::thin::cache::CacheClient< 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.

template<typename K, typename V>
bool ignite::thin::cache::CacheClient< K, V >::Replace ( const K &  key,
const V &  value 
)
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.

Parameters
keyKey to store in cache.
valueValue to be associated with the given key.
Returns
True if the value was replaced.

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