![]() |
GridGain C++
|
Cache client class template. More...
#include <cache_client.h>
Public Types | |
typedef K | KeyType |
Key type. | |
typedef V | ValueType |
Value type. | |
Public Member Functions | |
CacheClient (const 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 | Replace (const KeyType &key, const ValueType &oldVal, const ValueType &newVal) |
Stores given key-value pair in cache only if the previous value is equal to the old value passed as argument. 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... | |
bool | Remove (const KeyType &key, const ValueType &val) |
Removes given key mapping from cache if one exists and value is equal to the passed in value. 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 | GetAndPut (const KeyType &key, const ValueType &valIn, ValueType &valOut) |
Associates the specified value with the specified key in this cache, returning an existing value if one existed. More... | |
ValueType | GetAndPut (const KeyType &key, const ValueType &valIn) |
Associates the specified value with the specified key in this cache, returning an existing value if one existed. More... | |
void | GetAndRemove (const KeyType &key, ValueType &valOut) |
Atomically removes the entry for a key only if currently mapped to some value. More... | |
ValueType | GetAndRemove (const KeyType &key) |
Atomically removes the entry for a key only if currently mapped to some value. More... | |
void | GetAndReplace (const KeyType &key, const ValueType &valIn, ValueType &valOut) |
Atomically replaces the value for a given key if and only if there is a value currently mapped by the key. More... | |
ValueType | GetAndReplace (const KeyType &key, const ValueType &valIn) |
Atomically replaces the value for a given key if and only if there is a value currently mapped by the key. More... | |
bool | PutIfAbsent (const KeyType &key, const ValueType &val) |
Atomically associates the specified key with the given value if it is not already associated with a value. More... | |
void | GetAndPutIfAbsent (const KeyType &key, const ValueType &valIn, ValueType &valOut) |
Stores given key-value pair in cache only if cache had no previous mapping for it. More... | |
ValueType | GetAndPutIfAbsent (const KeyType &key, const ValueType &valIn) |
Stores given key-value pair in cache only if cache had no previous mapping for it. More... | |
query::QueryFieldsCursor | Query (const query::SqlFieldsQuery &qry) |
Perform SQL fields query. More... | |
query::QueryCursor< KeyType, ValueType > | Query (const query::ScanQuery &qry) |
Perform scan query. More... | |
query::continuous::ContinuousQueryHandleClient | QueryContinuous (query::continuous::ContinuousQueryClient< K, V > continuousQuery) |
Starts the continuous query execution. More... | |
void | RefreshAffinityMapping () |
Refresh affinity mapping. More... | |
Friends | |
class | impl::thin::cache::CacheClientProxy |
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 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.
K | Cache key type. |
V | Cache value type. |
|
inlineexplicit |
Constructor.
impl | Implementation. |
|
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.
key | Key to clear. |
|
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.
keys | Keys to clear. |
|
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.
begin | Iterator pointing to the beginning of the key sequence. |
end | Iterator pointing to the end of the key sequence. |
|
inline |
Check if the cache contains a value for the specified key.
key | Key whose presence in this cache is to be tested. |
true
if the cache contains specified key.
|
inline |
Check if cache contains mapping for these keys.
keys | Keys. |
|
inline |
Check if cache contains mapping for these keys.
begin | Iterator pointing to the beginning of the key sequence. |
end | Iterator pointing to the end of the key sequence. |
|
inline |
Get value from cache.
key | Key. |
|
inline |
Get value from the cache.
key | Key. |
value | Value. |
|
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.
keys | Keys. |
res | Map of key-value pairs. |
|
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.
begin | Iterator pointing to the beginning of the key sequence. |
end | Iterator pointing to the end of the key sequence. |
dst | Output iterator. Should dereference to std::pair or CacheEntry. |
|
inline |
Associates the specified value with the specified key in this cache, returning an existing value if one existed.
key | Key with which the specified value is to be associated. |
valIn | Value to be associated with the specified key. |
|
inline |
Associates the specified value with the specified key in this cache, returning an existing value if one existed.
key | Key with which the specified value is to be associated. |
valIn | Value to be associated with the specified key. |
valOut | The value associated with the key at the start of the operation or null if none was associated. |
|
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.
key | Key to store in cache. |
valIn | Value to be associated with the given key. |
|
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.
key | Key to store in cache. |
valIn | Value to be associated with the given key. |
valOut | Previously contained value regardless of whether put happened or not (null if there was no previous value). |
|
inline |
Atomically removes the entry for a key only if currently mapped to some value.
key | Key with which the specified value is to be associated. |
|
inline |
Atomically removes the entry for a key only if currently mapped to some value.
key | Key with which the specified value is to be associated. |
valOut | The value associated with the key at the start of the operation or null if none was associated. |
|
inline |
Atomically replaces the value for a given key if and only if there is a value currently mapped by the key.
key | Key with which the specified value is to be associated. |
valIn | Value to be associated with the specified key. |
|
inline |
Atomically replaces the value for a given key if and only if there is a value currently mapped by the key.
key | Key with which the specified value is to be associated. |
valIn | Value to be associated with the specified key. |
valOut | The value associated with the key at the start of the operation or null if none was associated. |
|
inline |
Gets the number of all entries cached across all nodes.
peekModes | Peek modes mask. |
|
inline |
Associate the specified value with the specified key in the cache.
key | Key. |
value | Value. |
|
inline |
Stores given key-value pairs in cache.
If write-through is enabled, the stored values will be persisted to store.
vals | Key-value pairs to store in cache. |
|
inline |
Stores given key-value pairs in cache.
If write-through is enabled, the stored values will be persisted to store.
begin | Iterator pointing to the beginning of the key-value pair sequence. |
end | Iterator pointing to the end of the key-value pair sequence. |
|
inline |
Atomically associates the specified key with the given value if it is not already associated with a value.
key | Key with which the specified value is to be associated. |
val | Value to be associated with the specified key. |
|
inline |
Perform scan query.
qry | Query. |
|
inline |
Perform SQL fields query.
qry | Query. |
|
inline |
Starts the continuous query execution.
continuousQuery | Continuous query. |
|
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.
|
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.
key | Key whose mapping is to be removed from cache. |
|
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.
key | Key whose mapping is to be removed from cache. |
val | Value to match against currently cached value. |
|
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.
|
inline |
Removes given key mappings from cache.
If write-through is enabled, the value will be removed from store.
keys | Keys whose mappings are to be removed from cache. |
|
inline |
Removes given key mappings from cache.
If write-through is enabled, the value will be removed from store.
begin | Iterator pointing to the beginning of the key sequence. |
end | Iterator pointing to the end of the key sequence. |
|
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.
key | Key to store in cache. |
value | Value to be associated with the given key. |
|
inline |
Stores given key-value pair in cache only if the previous value is equal to the old value passed as argument.
key | Key to store in cache. |
oldVal | Old value to match. |
newVal | Value to be associated with the given key. |