public interface GridCacheProjection<K,V> extends Iterable<GridCacheEntry<K,V>>, GridMetadataAware
'get(..)' methods to synchronously or asynchronously get values from cache.
All 'get(..)' methods are transactional and will participate in an ongoing transaction
if there is one.
'put(..)', 'putIfAbsent(..)', and 'replace(..)' methods to
synchronously or asynchronously put single or multiple entries into cache.
All these methods are transactional and will participate in an ongoing transaction
if there is one.
'remove(..)' methods to synchronously or asynchronously remove single or multiple keys
from cache. All 'remove(..)' methods are transactional and will participate in an ongoing transaction
if there is one.
'contains(..)' method to check if cache contains certain keys or values locally.
'forEach(..)', 'forAny(..)', and 'reduce(..)' methods to visit
every local cache entry within this projection.
flagsOn(..)', 'flagsOff(..)', and 'projection(..)' methods to
set specific flags and filters on a cache projection.
'keySet(..)', 'values(..)', and 'entrySet(..)' to provide
views on cache keys, values, and entries.
'peek(..)' methods to peek at values in global or transactional memory, swap
storage, or persistent storage.
'reload(..)' methods to reload latest values from persistent storage.
'promote(..)' methods to load specified keys from swap storage into
global cache memory.
'lock(..)', 'unlock(..)', and 'isLocked(..)' methods to acquire, release,
and check on distributed locks on a single or multiple keys in cache. All locking methods
are not transactional and will not enlist keys into ongoing transaction, if any.
'clear(..)' methods to clear elements from cache, and optionally from
swap storage. All 'clear(..)' methods are not transactional and will not enlist cleared
keys into ongoing transaction, if any.
'evict(..)' methods to evict elements from cache, and optionally store
them in underlying swap storage for later access. All 'evict(..)' methods are not
transactional and will not enlist evicted keys into ongoing transaction, if any.
'txStart(..)' methods to perform various cache
operations within a transaction (see GridCacheTx for more information).
queries() method to get an instance of GridCacheQueries service for working
with distributed cache queries.
'gridProjection(..)' methods which provide GridProjection only
for nodes on which given keys reside. All 'gridProjection(..)' methods are not
transactional and will not enlist keys into ongoing transaction.
toMap() to convert this interface into standard Java ConcurrentMap interface.
'x' provide the same functionality as their sibling
methods that don't end with 'x', however instead of returning a previous value they
return a boolean flag indicating whether operation succeeded or not. Returning
a previous value may involve a network trip or a persistent store lookup and should be
avoided whenever not needed.
'get(..)', 'put(..)', 'replace(..)',
and 'remove(..)' operations are transactional and will participate in an ongoing transaction,
if any. Other methods like 'peek(..)' or various 'contains(..)' methods may
be transaction-aware, i.e. check in-transaction entries first, but will not affect the current
state of transaction. See GridCacheTx documentation for more information
about transactions.
With affinity-based-group-locking the keys are grouped by affinity-key. This means that
only keys with identical affinity-key (see GridCacheAffinityKeyMapped) can participate in the
transaction, and only one lock on the affinity-key will be acquired for the whole transaction.
Affinity-group-locked transactions are started via
txStartAffinity(Object, GridCacheTxConcurrency, GridCacheTxIsolation, long, int) method.
With partition-based-group-locking the keys are grouped by partition ID. This means that
only keys belonging to identical partition (see GridCacheAffinity.partition(Object)) can participate in the
transaction, and only one lock on the whole partition will be acquired for the whole transaction.
Partition-group-locked transactions are started via
txStartPartition(int, GridCacheTxConcurrency, GridCacheTxIsolation, long, int) method.
Group locking should always be used for transactions whenever possible. If your requirements fit either affinity-based or partition-based scenarios outlined above then group-locking can significantly improve performance of your application, often by an order of magnitude.
null keys or values are allowed to be stored in cache. If a null value
happens to be in cache (e.g. after invalidation or remove), then cache will treat this case
as there is no value at all.
| Modifier and Type | Method and Description |
|---|---|
<K1,V1> GridCache<K1,V1> |
cache()
Gets base cache for this projection.
|
boolean |
clear(K key)
Clears an entry from this cache and swap storage only if the entry
is not currently locked, and is not participating in a transaction.
|
void |
clearAll()
Clears all entries from this cache only if the entry is not
currently locked or participating in a transaction.
|
boolean |
compact(K key)
Clears serialized value bytes from entry (if any) leaving only object representation.
|
void |
compactAll()
Clears serialized value bytes from cache entries (if any) leaving only object representation.
|
boolean |
containsKey(K key)
Returns
true if this cache contains a mapping for the specified
key. |
boolean |
containsValue(V val)
Returns
true if this cache contains given value. |
GridCacheEntry<K,V> |
entry(K key)
Gets entry from cache with the specified key.
|
Set<GridCacheEntry<K,V>> |
entrySet()
Gets set containing all cache entries.
|
Set<GridCacheEntry<K,V>> |
entrySet(int part)
Gets set containing cache entries that belong to provided partition or
null
if partition not found locally. |
boolean |
evict(K key)
Evicts entry associated with given key from cache.
|
void |
evictAll()
Attempts to evict all cache entries.
|
void |
evictAll(Collection<? extends K> keys)
Attempts to evict all entries associated with keys.
|
Set<GridCacheFlag> |
flags()
Gets cache flags enabled on this projection.
|
GridCacheProjection<K,V> |
flagsOff(GridCacheFlag... flags)
Gets cache projection base on this but with the specified flags turned off.
|
GridCacheProjection<K,V> |
flagsOn(GridCacheFlag... flags)
Gets cache projection base on this one, but with the specified flags turned on.
|
boolean |
forAll(GridPredicate<GridCacheEntry<K,V>> vis)
Tests whether the predicate holds for all entries.
|
void |
forEach(GridInClosure<GridCacheEntry<K,V>> vis)
Executes visitor closure on each cache element.
|
V |
get(K key)
Retrieves value mapped to the specified key from cache.
|
Map<K,V> |
getAll(Collection<? extends K> keys)
Retrieves values mapped to the specified keys from cache.
|
GridFuture<Map<K,V>> |
getAllAsync(Collection<? extends K> keys)
Asynchronously retrieves values mapped to the specified keys from cache.
|
GridFuture<V> |
getAsync(K key)
Asynchronously retrieves value mapped to the specified key from cache.
|
void |
globalClearAll()
Clears cache on all nodes that store it's data.
|
GridProjection |
gridProjection()
Gets grid projection for this cache.
|
boolean |
isEmpty()
Returns
true if this map contains no key-value mappings. |
boolean |
isLocked(K key)
Checks if any node owns a lock for this key.
|
boolean |
isLockedByThread(K key)
Checks if current thread owns a lock on this key.
|
Set<K> |
keySet()
Set of cached keys.
|
boolean |
lock(K key,
long timeout,
GridPredicate<GridCacheEntry<K,V>>... filter)
Synchronously acquires lock on a cached object with given
key only if the passed in filter (if any) passes.
|
boolean |
lockAll(Collection<? extends K> keys,
long timeout,
GridPredicate<GridCacheEntry<K,V>>... filter)
All or nothing synchronous lock for passed in keys.
|
GridFuture<Boolean> |
lockAllAsync(Collection<? extends K> keys,
long timeout,
GridPredicate<GridCacheEntry<K,V>>... filter)
All or nothing synchronous lock for passed in keys.
|
GridFuture<Boolean> |
lockAsync(K key,
long timeout,
GridPredicate<GridCacheEntry<K,V>>... filter)
Asynchronously acquires lock on a cached object with given
key only if the passed in filter (if any) passes.
|
String |
name()
Gets name of this cache (
null for default cache). |
int |
nearSize()
Gets size of near cache key set.
|
V |
peek(K key)
Peeks at in-memory cached value using default
GridCachePeekMode.SMART
peek mode. |
V |
peek(K key,
Collection<GridCachePeekMode> modes)
Peeks at cached value using optional set of peek modes.
|
Set<GridCacheEntry<K,V>> |
primaryEntrySet()
Gets set containing cache entries for which local node is the primary node.
|
Set<K> |
primaryKeySet()
Set of cached primary keys for which local node is the primary node.
|
int |
primarySize()
Gets size of all primary keys for this cache.
|
Collection<V> |
primaryValues()
Collection of primary cached values.for which local node is the primary node.
|
<K1,V1> GridCacheProjection<K1,V1> |
projection(Class<? super K1> keyType,
Class<? super V1> valType)
Gets cache projection only for given key and value type.
|
GridCacheProjection<K,V> |
projection(GridBiPredicate<K,V> p)
Gets cache projection based on given key-value predicate.
|
GridCacheProjection<K,V> |
projection(GridPredicate<GridCacheEntry<K,V>> filter)
Gets cache projection based on given entry filter.
|
V |
promote(K key)
This method promotes cache entry from offheap by given key, if any, from offheap or swap storage
into memory.
|
void |
promoteAll(Collection<? extends K> keys)
This method unswaps cache entries by given keys, if any, from swap storage
into memory.
|
V |
put(K key,
V val,
GridPredicate<GridCacheEntry<K,V>>... filter)
Stores given key-value pair in cache.
|
void |
putAll(Map<? extends K,? extends V> m,
GridPredicate<GridCacheEntry<K,V>>... filter)
Stores given key-value pairs in cache.
|
GridFuture<?> |
putAllAsync(Map<? extends K,? extends V> m,
GridPredicate<GridCacheEntry<K,V>>... filter)
Asynchronously stores given key-value pairs in cache.
|
GridFuture<V> |
putAsync(K key,
V val,
GridPredicate<GridCacheEntry<K,V>>... filter)
Asynchronously stores given key-value pair in cache.
|
V |
putIfAbsent(K key,
V val)
Stores given key-value pair in cache only if cache had no previous mapping for it.
|
GridFuture<V> |
putIfAbsentAsync(K key,
V val)
Asynchronously stores given key-value pair in cache only if cache had no previous mapping for it.
|
boolean |
putx(K key,
V val,
GridPredicate<GridCacheEntry<K,V>>... filter)
Stores given key-value pair in cache.
|
GridFuture<Boolean> |
putxAsync(K key,
V val,
GridPredicate<GridCacheEntry<K,V>>... filter)
Stores given key-value pair in cache.
|
boolean |
putxIfAbsent(K key,
V val)
Stores given key-value pair in cache only if cache had no previous mapping for it.
|
GridFuture<Boolean> |
putxIfAbsentAsync(K key,
V val)
Asynchronously stores given key-value pair in cache only if cache had no previous mapping for it.
|
GridCacheQueries<K,V> |
queries()
Returns queries facade responsible for creating various SQL, TEXT, or SCAN queries.
|
V |
reload(K key)
Reloads a single key from persistent storage.
|
void |
reloadAll()
Reloads all currently cached keys form persistent storage.
|
void |
reloadAll(Collection<? extends K> keys)
Reloads specified entries from underlying persistent storage.
|
GridFuture<?> |
reloadAllAsync()
Asynchronously reloads all specified entries from underlying
persistent storage.
|
GridFuture<?> |
reloadAllAsync(Collection<? extends K> keys)
Asynchronously reloads all specified entries from underlying
persistent storage.
|
GridFuture<V> |
reloadAsync(K key)
Asynchronously reloads a single key from persistent storage.
|
V |
remove(K key,
GridPredicate<GridCacheEntry<K,V>>... filter)
Removes given key mapping from cache.
|
boolean |
remove(K key,
V val)
Removes given key mapping from cache if one exists and value is equal to the passed in value.
|
void |
removeAll(Collection<? extends K> keys,
GridPredicate<GridCacheEntry<K,V>>... filter)
Removes given key mappings from cache for entries for which the optionally passed in filters do
pass.
|
void |
removeAll(GridPredicate<GridCacheEntry<K,V>>... filter)
Removes mappings from cache for entries for which the optionally passed in filters do
pass.
|
GridFuture<?> |
removeAllAsync(Collection<? extends K> keys,
GridPredicate<GridCacheEntry<K,V>>... filter)
Asynchronously removes given key mappings from cache for entries for which the optionally
passed in filters do pass.
|
GridFuture<?> |
removeAllAsync(GridPredicate<GridCacheEntry<K,V>>... filter)
Asynchronously removes mappings from cache for entries for which the optionally passed in filters do
pass.
|
GridFuture<V> |
removeAsync(K key,
GridPredicate<GridCacheEntry<K,V>>... filter)
Asynchronously removes given key mapping from cache.
|
GridFuture<Boolean> |
removeAsync(K key,
V val)
Asynchronously removes given key mapping from cache if one exists and value is equal to the passed in value.
|
boolean |
removex(K key,
GridPredicate<GridCacheEntry<K,V>>... filter)
Removes given key mapping from cache.
|
GridFuture<Boolean> |
removexAsync(K key,
GridPredicate<GridCacheEntry<K,V>>... filter)
Asynchronously removes given key mapping from cache.
|
V |
replace(K key,
V val)
Stores given key-value pair in cache only if if there is a previous mapping for it.
|
boolean |
replace(K key,
V oldVal,
V newVal)
Stores given key-value pair in cache only if only if the previous value is equal to the
'oldVal' passed in. |
GridFuture<V> |
replaceAsync(K key,
V val)
Asynchronously stores given key-value pair in cache only if if there is a previous mapping for it.
|
GridFuture<Boolean> |
replaceAsync(K key,
V oldVal,
V newVal)
Asynchronously stores given key-value pair in cache only if only if the previous value is equal to the
'oldVal' passed in. |
boolean |
replacex(K key,
V val)
Stores given key-value pair in cache only if only if there is a previous mapping for it.
|
GridFuture<Boolean> |
replacexAsync(K key,
V val)
Asynchronously stores given key-value pair in cache only if only if there is a previous mapping for it.
|
int |
size()
Gets size of cache key set.
|
ConcurrentMap<K,V> |
toMap()
Converts this API into standard Java
ConcurrentMap interface. |
void |
transform(K key,
GridClosure<V,V> transformer)
Stores result of applying
valTransform closure to the previous value associated with
given key in cache. |
void |
transformAll(Map<? extends K,? extends GridClosure<V,V>> m)
Stores result of applying transform closures from the given map to previous values associated
with corresponding keys in cache.
|
void |
transformAll(Set<? extends K> keys,
GridClosure<V,V> transformer)
Stores result of applying the specified transform closure to previous values associated
with the specified keys in cache.
|
GridFuture<?> |
transformAllAsync(Map<? extends K,? extends GridClosure<V,V>> m)
Stores result of applying transform closures from the given map to previous values associated
with corresponding keys in cache.
|
GridFuture<?> |
transformAllAsync(Set<? extends K> keys,
GridClosure<V,V> transformer)
Stores result of applying the specified transform closure to previous values associated
with the specified keys in cache.
|
<R> R |
transformAndCompute(K key,
GridClosure<V,GridBiTuple<V,R>> transformer)
Applies
transformer closure to the previous value associated with given key in cache,
closure should return GridBiTuple instance where first value is new value stored in cache
and second value is returned as result of this method. |
GridFuture<?> |
transformAsync(K key,
GridClosure<V,V> transformer)
Stores result of applying
transformer closure to the previous value associated with
given key in cache. |
GridCacheTx |
tx()
Gets transaction started by this thread or
null if this thread does
not have a transaction. |
GridCacheTx |
txStart()
Starts transaction with default isolation, concurrency, timeout, and invalidation policy.
|
GridCacheTx |
txStart(GridCacheTxConcurrency concurrency,
GridCacheTxIsolation isolation)
Starts new transaction with the specified concurrency and isolation.
|
GridCacheTx |
txStart(GridCacheTxConcurrency concurrency,
GridCacheTxIsolation isolation,
long timeout,
int txSize)
Starts transaction with specified isolation, concurrency, timeout, invalidation flag,
and number of participating entries.
|
GridCacheTx |
txStartAffinity(Object affinityKey,
GridCacheTxConcurrency concurrency,
GridCacheTxIsolation isolation,
long timeout,
int txSize)
Starts
affinity-group-locked transaction based on affinity key. |
GridCacheTx |
txStartPartition(int partId,
GridCacheTxConcurrency concurrency,
GridCacheTxIsolation isolation,
long timeout,
int txSize)
Starts
partition-group-locked transaction based on partition ID. |
void |
unlock(K key,
GridPredicate<GridCacheEntry<K,V>>... filter)
Unlocks given key only if current thread owns the lock.
|
void |
unlockAll(Collection<? extends K> keys,
GridPredicate<GridCacheEntry<K,V>>... filter)
Unlocks given keys only if current thread owns the locks.
|
Collection<V> |
values()
Collection of cached values.
|
addMeta, addMetaIfAbsent, addMetaIfAbsent, allMeta, copyMeta, copyMeta, hasMeta, hasMeta, meta, putMetaIfAbsent, putMetaIfAbsent, removeMeta, removeMeta, replaceMetaString name()
null for default cache).GridProjection gridProjection()
<K1,V1> GridCache<K1,V1> cache()
K1 - Cache key type.V1 - Cache value type.Set<GridCacheFlag> flags()
GridCacheQueries<K,V> queries()
<K1,V1> GridCacheProjection<K1,V1> projection(Class<? super K1> keyType, Class<? super V1> valType)
non-null key-value
pairs that have matching key and value pairs will be used in this projection.K1 - Key type.V1 - Value type.keyType - Key type.valType - Value type.GridCacheProjection<K,V> projection(@Nullable GridBiPredicate<K,V> p)
For example, for putAll(Map, GridPredicate[]) method only
elements that pass the filter will be given to GridCache.putAll(m, filter)
where it will be checked once again prior to put.
p - Key-value predicate for this projection. If null, then the
same projection is returned.GridCacheProjection<K,V> projection(@Nullable GridPredicate<GridCacheEntry<K,V>> filter)
projection(GridBiPredicate)
method, this filter will not be used for pre-filtering.filter - Filter to be passed through to all cache operations. If null, then the
same projection is returned. If cache operation receives its own filter, then filters
will be 'anded'.GridCacheProjection<K,V> flagsOn(@Nullable GridCacheFlag... flags)
flags - Flags to turn on (if empty, then no-op).GridCacheProjection<K,V> flagsOff(@Nullable GridCacheFlag... flags)
flags - Flags to turn off (if empty, then all flags will be turned off).boolean isEmpty()
true if this map contains no key-value mappings.true if this map contains no key-value mappings.ConcurrentMap<K,V> toMap()
ConcurrentMap interface.ConcurrentMap representation of given cache projection.boolean containsKey(K key)
true if this cache contains a mapping for the specified
key.key - key whose presence in this map is to be tested.true if this map contains a mapping for the specified key.NullPointerException - if the key is null.boolean containsValue(V val)
true if this cache contains given value.val - Value to check.True if given value is present in cache.NullPointerException - if the value is null.void forEach(GridInClosure<GridCacheEntry<K,V>> vis)
vis - Closure which will be invoked for each cache entry.boolean forAll(GridPredicate<GridCacheEntry<K,V>> vis)
true is returned.
vis - Predicate to test for each cache entry.True if the given predicate holds for all visited entries, false otherwise.@Nullable V reload(K key) throws GridException
GridCacheStore.load(GridCacheTx, Object)
method.
key - Key to reload.GridException - If reloading failed.GridFuture<V> reloadAsync(K key)
GridCacheStore.load(GridCacheTx, Object)
method.
key - Key to reload.void reloadAll()
throws GridException
GridException - If reloading failed.GridFuture<?> reloadAllAsync()
reload completes.void reloadAll(@Nullable Collection<? extends K> keys) throws GridException
keys - Keys to reload.GridException - if reloading failed.GridFuture<?> reloadAllAsync(@Nullable Collection<? extends K> keys)
keys - Keys to reload.reload completes.@Nullable V peek(K key)
GridCachePeekMode.SMART
peek mode.
This method will not load value from any persistent store or from a remote node.
GridCachePeekMode.SMART mode
semantics. If you need to look at global cached value even from within transaction,
you can use peek(Object, Collection) method.key - Entry key.NullPointerException - If key is null.@Nullable V peek(K key, @Nullable Collection<GridCachePeekMode> modes) throws GridException
non-null value is found, it will be immediately returned.
Note that if modes are not provided this method works exactly the same way as
peek(Object), implicitly using GridCachePeekMode.SMART mode.
key - Entry key.modes - Optional set of peek modes.GridException - If peek operation failed.NullPointerException - If key is null.@Nullable V get(K key) throws GridException
null
means entry did not pass the provided filter or cache has no mapping for the
key.
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 disable, and if read-through is allowed, value
will be loaded from GridCacheStore persistent storage via
GridCacheStore.load(GridCacheTx, Object) method.
GridCacheFlag.LOCAL flag is set on projection.key - Key to retrieve the value for.GridException - If get operation failed.GridCacheFlagException - If failed projection flags validation.NullPointerException - if the key is null.GridFuture<V> getAsync(K key)
null
means entry did not pass the provided filter or cache has no mapping for the
key.
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 GridCacheStore persistent storage via
GridCacheStore.load(GridCacheTx, Object) method.
GridCacheFlag.LOCAL flag is set on projection.key - Key for the value to get.NullPointerException - if the key is null.GridCacheFlagException - If projection flags validation failed.Map<K,V> getAll(@Nullable Collection<? extends K> keys) throws GridException
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 GridCacheStore persistent storage via
GridCacheStore.loadAll(GridCacheTx, Collection, GridBiInClosure) method.
GridCacheFlag.LOCAL flag is set on projection.keys - Keys to get.GridException - If get operation failed.GridCacheFlagException - If failed projection flags validation.GridFuture<Map<K,V>> getAllAsync(@Nullable Collection<? extends K> keys)
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 GridCacheStore persistent storage via
GridCacheStore.loadAll(GridCacheTx, Collection, GridBiInClosure) method.
GridCacheFlag.LOCAL flag is set on projection.keys - Key for the value to get.GridCacheFlagException - If projection flags validation failed.@Nullable V put(K key, V val, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter) throws GridException
GridCacheMode.PARTITIONED or GridCacheMode.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 value has to be loaded from persistent
storage, GridCacheStore.load(GridCacheTx, Object) method will be used.
If the returned value is not needed, method putx(Object, Object, GridPredicate[]) 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 stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key to store in cache.val - Value to be associated with the given key.filter - Optional filter to check prior to putting value in cache. Note
that filter check is atomic with put operation.null
if entry did not pass the filter, or if there was no mapping for the key in swap
or in persistent storage.NullPointerException - If either key or value are null.GridException - If put operation failed.GridCacheFlagException - If projection flags validation failed.GridFuture<V> putAsync(K key, V val, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter)
GridCacheMode.REPLICATED caches, the value will be loaded from swap
and, if it's not there, and read-through is allowed, from the underlying
GridCacheStore storage. In case of GridCacheMode.PARTITIONED 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 and read-through is allowed,
from the underlying persistent storage. If value has to be loaded from persistent
storage, GridCacheStore.load(GridCacheTx, Object) method will be used.
If the returned value is not needed, method putx(Object, Object, GridPredicate[]) 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 stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key to store in cache.val - Value to be associated with the given key.filter - Optional filter to check prior to putting value in cache. Note
that filter check is atomic with put operation.NullPointerException - If either key or value are null.GridCacheFlagException - If projection flags validation failed.boolean putx(K key, V val, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter) throws GridException
This method will return true if value is stored in cache and false otherwise.
Unlike put(Object, Object, GridPredicate[]) method, it does not return previous
value and, therefore, does not have any overhead associated with returning a value. It
should be used whenever return value is not required.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key to store in cache.val - Value to be associated with the given key.filter - Optional filter to check prior to putting value in cache. Note
that filter check is atomic with put operation.True if optional filter passed and value was stored in cache,
false otherwise. Note that this method will return true if filter is not
specified.NullPointerException - If either key or value are null.GridException - If put operation failed.GridCacheFlagException - If projection flags validation failed.GridFuture<Boolean> putxAsync(K key, V val, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter)
This method will return true if value is stored in cache and false otherwise.
Unlike put(Object, Object, GridPredicate[]) method, it does not return previous
value and, therefore, does not have any overhead associated with returning of a value. It
should always be used whenever return value is not required.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key to store in cache.val - Value to be associated with the given key.filter - Optional filter to check prior to putting value in cache. Note
that filter check is atomic with put operation.true if optional filter
passed and value was stored in cache, false otherwise. Note that future will
return true if filter is not specified.NullPointerException - If either key or value are null.GridCacheFlagException - If projection flags validation failed.void transform(K key, GridClosure<V,V> transformer) throws GridException
valTransform closure to the previous value associated with
given key in cache. Result of closure application is guaranteed to be atomic, however, closure
itself can be applied more than once.
Note that transform closure must not throw any exceptions. If exception is thrown from apply
method, the transaction will be invalidated and entries participating in transaction will be nullified.
Unlike putx(Object, Object, GridPredicate[]) or put(Object, Object, GridPredicate[])
methods, this method will not transfer the whole updated value over the network, but instead will
transfer the transforming closure that will be applied on each remote node involved in transaction.
It may add significant performance gain when dealing with large values as the value is much larger
than the closure itself. If write-through is enabled, the stored value will be persisted to
GridCacheStore via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key to store in cache.transformer - Closure to be applied to the previous value in cache. If this closure returns
null, the associated value will be removed from cache.NullPointerException - If either key or transform closure is null.GridException - On any error occurred while storing value in cache.<R> R transformAndCompute(K key, GridClosure<V,GridBiTuple<V,R>> transformer) throws GridException
transformer closure to the previous value associated with given key in cache,
closure should return GridBiTuple instance where first value is new value stored in cache
and second value is returned as result of this method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key to store in cache.transformer - Closure to be applied to the previous value in cache.GridException - On any error occurred while storing value in cache.GridFuture<?> transformAsync(K key, GridClosure<V,V> transformer)
transformer closure to the previous value associated with
given key in cache. Result of closure application is guaranteed to be atomic, however, closure
itself can be applied more than once.
Note that transform closure must not throw any exceptions. If exception is thrown from apply
method, the transaction will be invalidated and entries participating in transaction will be nullified.
Unlike putx(Object, Object, GridPredicate[]) method, this method will not transfer
the whole updated value over the network, but instead will transfer the transforming closure
that will be applied on each remote node involved in transaction. It may add significant performance
gain when dealing with large values as the value is much larger than the closure itself.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key to store in cache.transformer - Closure to be applied to the previous value in cache. If this closure returns
null, the associated value will be removed from cache.NullPointerException - If either key or transform closure is null.@Nullable V putIfAbsent(K key, V val) throws GridException
GridCacheMode.PARTITIONED or GridCacheMode.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 value has to be loaded from persistent
storage, GridCacheStore.load(GridCacheTx, Object) method will be used.
If the returned value is not needed, method putxIfAbsent(Object, Object) 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 stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key to store in cache.val - Value to be associated with the given key.NullPointerException - If either key or value are null.GridException - If put operation failed.GridCacheFlagException - If projection flags validation failed.GridFuture<V> putIfAbsentAsync(K key, V val)
GridCacheMode.PARTITIONED or GridCacheMode.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 value has to be loaded from persistent
storage, GridCacheStore.load(GridCacheTx, Object) method will be used.
If the returned value is not needed, method putxIfAbsentAsync(Object, Object) 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 stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key to store in cache.val - Value to be associated with the given key.NullPointerException - If either key or value are null.GridCacheFlagException - If projection flags validation failed.boolean putxIfAbsent(K key, V val) throws GridException
This method will return true if value is stored in cache and false otherwise.
Unlike putIfAbsent(Object, Object) method, it does not return previous
value and, therefore, does not have any overhead associated with returning of a value. It
should always be used whenever return value is not required.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key to store in cache.val - Value to be associated with the given key.true if value is stored in cache and false otherwise.NullPointerException - If either key or value are null.GridException - If put operation failed.GridCacheFlagException - If projection flags validation failed.GridFuture<Boolean> putxIfAbsentAsync(K key, V val)
This method will return true if value is stored in cache and false otherwise.
Unlike putIfAbsent(Object, Object) method, it does not return previous
value and, therefore, does not have any overhead associated with returning of a value. It
should always be used whenever return value is not required.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key to store in cache.val - Value to be associated with the given key.NullPointerException - If either key or value are null.GridCacheFlagException - If projection flags validation failed.@Nullable V replace(K key, V val) throws GridException
GridCacheMode.PARTITIONED or GridCacheMode.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 value has to be loaded from persistent
storage, GridCacheStore.load(GridCacheTx, Object) method will be used.
If the returned value is not needed, method replacex(Object, Object) 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 stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key to store in cache.val - Value to be associated with the given key.NullPointerException - If either key or value are null.GridException - If replace operation failed.GridCacheFlagException - If projection flags validation failed.GridFuture<V> replaceAsync(K key, V val)
GridCacheMode.PARTITIONED 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 value has to be loaded from persistent
storage, GridCacheStore.load(GridCacheTx, Object) method will be used.
If the returned value is not needed, method replacex(Object, Object) 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 stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key to store in cache.val - Value to be associated with the given key.NullPointerException - If either key or value are null.GridCacheFlagException - If projection flags validation failed.boolean replacex(K key, V val) throws GridException
This method will return true if value is stored in cache and false otherwise.
Unlike replace(Object, Object) method, it does not return previous
value and, therefore, does not have any overhead associated with returning of a value. It
should always be used whenever return value is not required.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key to store in cache.val - Value to be associated with the given key.True if replace happened, false otherwise.NullPointerException - If either key or value are null.GridException - If replace operation failed.GridCacheFlagException - If projection flags validation failed.GridFuture<Boolean> replacexAsync(K key, V val)
This method will return true if value is stored in cache and false otherwise.
Unlike replaceAsync(Object, Object) method, it does not return previous
value and, therefore, does not have any overhead associated with returning of a value. It
should always be used whenever return value is not required.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key to store in cache.val - Value to be associated with the given key.NullPointerException - If either key or value are null.GridCacheFlagException - If projection flags validation failed.boolean replace(K key, V oldVal, V newVal) throws GridException
'oldVal' passed in.
This method will return true if value is stored in cache and false otherwise.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key to store in cache.oldVal - Old value to match.newVal - Value to be associated with the given key.True if replace happened, false otherwise.NullPointerException - If either key or value are null.GridException - If replace operation failed.GridCacheFlagException - If projection flags validation failed.GridFuture<Boolean> replaceAsync(K key, V oldVal, V newVal)
'oldVal' passed in.
This method will return true if value is stored in cache and false otherwise.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key to store in cache.oldVal - Old value to match.newVal - Value to be associated with the given key.NullPointerException - If either key or value are null.GridCacheFlagException - If projection flags validation failed.void putAll(@Nullable Map<? extends K,? extends V> m, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter) throws GridException
If write-through is enabled, the stored values will be persisted to GridCacheStore
via GridCacheStore.putAll(GridCacheTx, Map) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.m - Key-value pairs to store in cache.filter - Optional entry filter. If provided, then entry will
be stored only if the filter returned true.GridException - If put operation failed.GridCacheFlagException - If projection flags validation failed.void transformAll(@Nullable Map<? extends K,? extends GridClosure<V,V>> m) throws GridException
Note that transform closure must not throw any exceptions. If exception is thrown from apply
method, the transaction will be invalidated and entries participating in transaction will be nullified.
Unlike putAll(Map, GridPredicate[]) method, this method will not transfer
the whole updated value over the network, but instead will transfer the transforming closures
that will be applied on each remote node involved in transaction. It may add significant
performance gain when dealing with large values as the value is much larger than the closure itself.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.m - Map containing keys and closures to be applied to values.GridException - On any error occurred while storing value in cache.void transformAll(@Nullable Set<? extends K> keys, GridClosure<V,V> transformer) throws GridException
Note that transform closure must not throw any exceptions. If exception is thrown from apply
method, the transaction will be invalidated and entries participating in transaction will be nullified.
Unlike putAll(Map, GridPredicate[]) method, this method will not transfer
the whole updated value over the network, but instead will transfer the transforming closure
that will be applied on each remote node involved in transaction. It may add significant
performance gain when dealing with large values as the value is much larger than the closure itself.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.keys - Keys for entries, to which the transformation closure will be applied.
If the collection is null or empty, this method is no-op.transformer - Transformation closure to be applied to each value.GridException - On any error occurred while storing value in cache.GridFuture<?> putAllAsync(@Nullable Map<? extends K,? extends V> m, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter)
If write-through is enabled, the stored values will be persisted to GridCacheStore
via GridCacheStore.putAll(GridCacheTx, Map) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.m - Key-value pairs to store in cache.filter - Optional entry filter. If provided, then entry will
be stored only if the filter returned true.GridCacheFlagException - If projection flags validation failed.GridFuture<?> transformAllAsync(@Nullable Map<? extends K,? extends GridClosure<V,V>> m)
Note that transform closure must not throw any exceptions. If exception is thrown from apply
method, the transaction will be invalidated and entries participating in transaction will be nullified.
Unlike putAll(Map, GridPredicate[]) method, this method will not transfer
the whole updated value over the network, but instead will transfer the transforming closures
that will be applied on each remote node involved in transaction. It may add significant performance
gain when dealing with large values as the value is much larger than the closure itself.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.m - Map containing keys and closures to be applied to values.GridFuture<?> transformAllAsync(@Nullable Set<? extends K> keys, GridClosure<V,V> transformer) throws GridException
Note that transform closure must not throw any exceptions. If exception is thrown from apply
method, the transaction will be invalidated and entries participating in transaction will be nullified.
Unlike putAll(Map, GridPredicate[]) method, this method will not transfer
the whole updated value over the network, but instead will transfer the transforming closure
that will be applied on each remote node involved in transaction. It may add significant
performance gain when dealing with large values as the value is much larger than the closure itself.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.keys - Keys for entries, to which the transformation closure will be applied.
If the collection is null or empty, this method is no-op.transformer - Transformation closure to be applied to each value.GridException - On any error occurred while storing value in cache.Set<K> keySet()
Iterator over this set will not fail if set was concurrently updated by another thread. This means that iterator may or may not return latest keys depending on whether they were added before or after current iterator position.
Set<K> primaryKeySet()
null because they were invalidated. You can remove elements from
this set, but you cannot add elements to this set. All removal operation will be
reflected on the cache itself.
Iterator over this set will not fail if set was concurrently updated by another thread. This means that iterator may or may not return latest keys depending on whether they were added before or after current iterator position.
Collection<V> values()
null because they were invalided. You can remove
elements from this collection, but you cannot add elements to this collection.
All removal operation will be reflected on the cache itself.
If filter is provided, then only the values for the entries that pass provided filters are returned.
Iterator over this collection will not fail if collection was concurrently updated by another thread. This means that iterator may or may not return latest values depending on whether they were added before or after current iterator position.
Collection<V> primaryValues()
null
because they were invalided. You can remove elements from this collection,
but you cannot add elements to this collection. All removal operation will be
reflected on the cache itself.
If filter is provided, then only the values for the entries that pass provided filters are returned.
Iterator over this collection will not fail if collection was concurrently updated by another thread. This means that iterator may or may not return latest values depending on whether they were added before or after current iterator position.
Set<GridCacheEntry<K,V>> entrySet()
If optional filters are provided, then only entries that successfully pass the filters will be included in the resulting set.
@Nullable Set<GridCacheEntry<K,V>> entrySet(int part)
null
if partition not found locally.part - Partition.null if partition
not found locally.Set<GridCacheEntry<K,V>> primaryEntrySet()
If optional filters are provided, then only entries that successfully pass the filters will be included in the resulting set.
GridCacheTx txStart() throws IllegalStateException
GridCacheConfiguration at startup.IllegalStateException - If transaction is already started by this thread.UnsupportedOperationException - If cache is GridCacheAtomicityMode.ATOMIC.GridCacheTx txStart(GridCacheTxConcurrency concurrency, GridCacheTxIsolation isolation)
concurrency - Concurrency.isolation - Isolation.IllegalStateException - If transaction is already started by this thread.UnsupportedOperationException - If cache is GridCacheAtomicityMode.ATOMIC.GridCacheTx txStart(GridCacheTxConcurrency concurrency, GridCacheTxIsolation isolation, long timeout, int txSize)
concurrency - Concurrency.isolation - Isolation.timeout - Timeout.txSize - Number of entries participating in transaction (may be approximate).IllegalStateException - If transaction is already started by this thread.UnsupportedOperationException - If cache is GridCacheAtomicityMode.ATOMIC.GridCacheTx txStartAffinity(Object affinityKey, GridCacheTxConcurrency concurrency, GridCacheTxIsolation isolation, long timeout, int txSize) throws IllegalStateException, GridException
affinity-group-locked transaction based on affinity key. In this mode only affinity key
is locked and all other entries in transaction are written without locking. However,
all keys in such transaction must have the same affinity key. Node on which transaction
is started must be primary for the given affinity key (an exception is thrown otherwise).
Since only affinity key is locked, and no individual keys, it is user's responsibility to make sure
there are no other concurrent explicit updates directly on individual keys participating in the
transaction. All updates to the keys involved should always go through affinity-group-locked
transaction, otherwise cache may be left in inconsistent state.
If cache sanity check is enabled (GridConfiguration.isCacheSanityCheckEnabled()),
the following checks are performed:
affinityKey - Affinity key for all entries updated by transaction. This node
must be primary for this key.timeout - Timeout (0 for default).txSize - Number of entries participating in transaction (may be approximate), 0 for default.concurrency - Transaction concurrency control.isolation - Cache transaction isolation level.IllegalStateException - If transaction is already started by this thread.GridException - If local node is not primary for any of provided keys.UnsupportedOperationException - If cache is GridCacheAtomicityMode.ATOMIC.GridCacheTx txStartPartition(int partId, GridCacheTxConcurrency concurrency, GridCacheTxIsolation isolation, long timeout, int txSize) throws IllegalStateException, GridException
partition-group-locked transaction based on partition ID. In this mode the whole partition
is locked and all other entries in transaction are written without locking. However,
all keys in such transaction must belong to the same partition. Node on which transaction
is started must be primary for the given partition (an exception is thrown otherwise).
Since only partition is locked, and no individual keys, it is user's responsibility to make sure
there are no other concurrent explicit updates directly on individual keys participating in the
transaction. All updates to the keys involved should always go through partition-group-locked
transaction, otherwise, cache may be left in inconsistent state.
If cache sanity check is enabled (GridConfiguration.isCacheSanityCheckEnabled()),
the following checks are performed:
partId - Partition id for which transaction is started. This node
must be primary for this partition.timeout - Timeout (0 for default).txSize - Number of entries participating in transaction (may be approximate), 0 for default.concurrency - Transaction concurrency control.isolation - Cache transaction isolation level.IllegalStateException - If transaction is already started by this thread.GridException - If local node is not primary for any of provided keys.UnsupportedOperationException - If cache is GridCacheAtomicityMode.ATOMIC.@Nullable GridCacheTx tx()
null if this thread does
not have a transaction.null if this thread
does not have a transaction.@Nullable GridCacheEntry<K,V> entry(K key)
Note that this method can return null if projection is configured as
pre-filtered and entry key and value don't pass key-value filter of the projection.
key - Entry key.null if projection pre-filtering was not passed.boolean evict(K key)
If GridCacheConfiguration.isSwapEnabled() is set to true and
GridCacheFlag.SKIP_SWAP is not enabled, the evicted entry will
be swapped to offheap, and then to disk.
GridCacheFlag.READ.key - Key to evict from cache.True if entry could be evicted, false otherwise.void evictAll()
If GridCacheConfiguration.isSwapEnabled() is set to true and
GridCacheFlag.SKIP_SWAP is not enabled, the evicted entry will
be swapped to offheap, and then to disk.
GridCacheFlag.READ.void evictAll(@Nullable Collection<? extends K> keys)
If GridCacheConfiguration.isSwapEnabled() is set to true and
GridCacheFlag.SKIP_SWAP is not enabled, the evicted entry will
be swapped to offheap, and then to disk.
GridCacheFlag.READ.keys - Keys to evict.void clearAll()
If GridCacheConfiguration.isSwapEnabled() is set to true and
GridCacheFlag.SKIP_SWAP is not enabled, the evicted entries will
also be cleared from swap.
Note that this operation is local as it merely clears entries from local cache. It does not remove entries from remote caches or from underlying persistent storage.
GridCacheFlag.READ.boolean clear(K key)
If GridCacheConfiguration.isSwapEnabled() is set to true and
GridCacheFlag.SKIP_SWAP is not enabled, the evicted entries will
also be cleared from swap.
Note that this operation is local as it merely clears an entry from local cache. It does not remove entries from remote caches or from underlying persistent storage.
GridCacheFlag.READ.key - Key to clear.True if entry was successfully cleared from cache, false
if entry was in use at the time of this method invocation and could not be
cleared.void globalClearAll()
throws GridException
clearAll() method which only
clears local node's cache.
GridGain will make the best attempt to clear caches on all nodes. If some caches could not be cleared, then exception will be thrown.
GridException - In case of cache could not be cleared on any of the nodes.boolean compact(K key) throws GridException
key - Key to compact.true if entry was deleted from cache (i.e. was expired).GridException - If failed to compact.void compactAll()
throws GridException
GridException - If failed to compact.@Nullable V remove(K key, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter) throws GridException
GridCacheMode.PARTITIONED or GridCacheMode.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 value has to be loaded from persistent
storage, GridCacheStore.load(GridCacheTx, Object) method will be used.
If the returned value is not needed, method removex(Object, GridPredicate[]) 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 GridCacheStore
via GridCacheStore.remove(GridCacheTx, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key whose mapping is to be removed from cache.filter - Optional filter to check prior to removing value form cache. Note
that filter is checked atomically together with remove operation.null
if there was no value for this key.NullPointerException - If key is null.GridException - If remove operation failed.GridCacheFlagException - If projection flags validation failed.GridFuture<V> removeAsync(K key, GridPredicate<GridCacheEntry<K,V>>... filter)
GridCacheMode.PARTITIONED or GridCacheMode.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 value has to be loaded from persistent
storage, GridCacheStore.load(GridCacheTx, Object) method will be used.
If the returned value is not needed, method removex(Object, GridPredicate[]) 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 GridCacheStore
via GridCacheStore.remove(GridCacheTx, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key whose mapping is to be removed from cache.filter - Optional filter to check prior to removing value form cache. Note
that filter is checked atomically together with remove operation.NullPointerException - if the key is null.GridCacheFlagException - If projection flags validation failed.boolean removex(K key, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter) throws GridException
This method will return true if remove did occur, which means that all optionally
provided filters have passed and there was something to remove, false otherwise.
If write-through is enabled, the value will be removed from GridCacheStore
via GridCacheStore.remove(GridCacheTx, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key whose mapping is to be removed from cache.filter - Optional filter to check prior to removing value form cache. Note
that filter is checked atomically together with remove operation.True if filter passed validation and entry was removed, false otherwise.
Note that if filter is not specified, this method will return true.NullPointerException - if the key is null.GridException - If remove failed.GridCacheFlagException - If projection flags validation failed.GridFuture<Boolean> removexAsync(K key, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter)
This method will return true if remove did occur, which means that all optionally
provided filters have passed and there was something to remove, false otherwise.
If write-through is enabled, the value will be removed from GridCacheStore
via GridCacheStore.remove(GridCacheTx, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key whose mapping is to be removed from cache.filter - Optional filter to check prior to removing value form cache. Note
that filter is checked atomically together with remove operation.true
if optional filters passed validation and remove did occur, false otherwise.
Note that if filter is not specified, this method will return true.NullPointerException - if the key is null.GridCacheFlagException - If projection flags validation failed.boolean remove(K key, V val) throws GridException
If write-through is enabled, the value will be removed from GridCacheStore
via GridCacheStore.remove(GridCacheTx, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key whose mapping is to be removed from cache.val - Value to match against currently cached value.True if entry was removed and passed in value matched the cached one,
false otherwise.NullPointerException - if the key or value is null.GridException - If remove failed.GridCacheFlagException - If projection flags validation failed.GridFuture<Boolean> removeAsync(K key, V val)
This method will return true if remove did occur, which means that all optionally
provided filters have passed and there was something to remove, false otherwise.
If write-through is enabled, the value will be removed from GridCacheStore
via GridCacheStore.remove(GridCacheTx, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key whose mapping is to be removed from cache.val - Value to match against currently cached value.true
if currently cached value will match the passed in one.NullPointerException - if the key or value is null.GridCacheFlagException - If projection flags validation failed.void removeAll(@Nullable Collection<? extends K> keys, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter) throws GridException
If write-through is enabled, the values will be removed from GridCacheStore
via GridCacheStore.removeAll(GridCacheTx, Collection) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.keys - Keys whose mappings are to be removed from cache.filter - Optional filter to check prior to removing value form cache. Note
that filter is checked atomically together with remove operation.GridException - If remove failed.GridCacheFlagException - If flags validation failed.GridFuture<?> removeAllAsync(@Nullable Collection<? extends K> keys, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter)
If write-through is enabled, the values will be removed from GridCacheStore
via GridCacheStore.removeAll(GridCacheTx, Collection) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.keys - Keys whose mappings are to be removed from cache.filter - Optional filter to check prior to removing value form cache. Note
that filter is checked atomically together with remove operation.GridCacheFlagException - If flags validation failed.void removeAll(@Nullable GridPredicate<GridCacheEntry<K,V>>... filter) throws GridException
null, then all entries in cache will be enrolled
into transaction.
USE WITH CARE - if your cache has many entries that pass through the filter or if filter is empty, then transaction will quickly become very heavy and slow. Also, locks are acquired in undefined order, so it may cause a deadlock when used with other concurrent transactional updates.
If write-through is enabled, the values will be removed from GridCacheStore
via GridCacheStore.removeAll(GridCacheTx, Collection) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.filter - Filter used to supply keys for remove operation (if null,
then nothing will be removed).GridException - If remove failed.GridCacheFlagException - If flags validation failed.GridFuture<?> removeAllAsync(@Nullable GridPredicate<GridCacheEntry<K,V>>... filter)
null, then all entries in cache will be enrolled
into transaction.
USE WITH CARE - if your cache has many entries that pass through the filter or if filter is empty, then transaction will quickly become very heavy and slow.
If write-through is enabled, the values will be removed from GridCacheStore
via GridCacheStore.removeAll(GridCacheTx, Collection) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.filter - Filter used to supply keys for remove operation (if null,
then nothing will be removed).GridCacheFlagException - If flags validation failed.boolean lock(K key, long timeout, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter) throws GridException
GridCacheTxConcurrency.PESSIMISTIC concurrency control for transaction
which will acquire explicit locks for relevant cache operations.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key to lock.timeout - Timeout in milliseconds to wait for lock to be acquired
('0' for no expiration), -1 for immediate failure if
lock cannot be acquired immediately).filter - Optional filter to validate prior to acquiring the lock.True if all filters passed and lock was acquired,
false otherwise.GridException - If lock acquisition resulted in error.GridCacheFlagException - If flags validation failed.GridFuture<Boolean> lockAsync(K key, long timeout, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter)
GridCacheTxConcurrency.PESSIMISTIC concurrency control for transaction
which will acquire explicit locks for relevant cache operations.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key to lock.timeout - Timeout in milliseconds to wait for lock to be acquired
('0' for no expiration, -1 for immediate failure if
lock cannot be acquired immediately).filter - Optional filter to validate prior to acquiring the lock.true
whenever all filters pass and locks are acquired before timeout is expired,
false otherwise.GridCacheFlagException - If flags validation failed.boolean lockAll(@Nullable Collection<? extends K> keys, long timeout, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter) throws GridException
GridCacheTxConcurrency.PESSIMISTIC concurrency control for transaction
which will acquire explicit locks for relevant cache operations.
GridCacheFlag.LOCAL, GridCacheFlag.READ.keys - Keys to lock.timeout - Timeout in milliseconds to wait for lock to be acquired
('0' for no expiration).filter - Optional filter that needs to atomically pass in order for the locks
to be acquired.True if all filters passed and locks were acquired before
timeout has expired, false otherwise.GridException - If lock acquisition resulted in error.GridCacheFlagException - If flags validation failed.GridFuture<Boolean> lockAllAsync(@Nullable Collection<? extends K> keys, long timeout, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter)
GridCacheTxConcurrency.PESSIMISTIC concurrency control for transaction
which will acquire explicit locks for relevant cache operations.
GridCacheFlag.LOCAL, GridCacheFlag.READ.keys - Keys to lock.timeout - Timeout in milliseconds to wait for lock to be acquired
('0' for no expiration).filter - Optional filter that needs to atomically pass in order for the locks
to be acquired.true if all filters passed and locks were acquired before
timeout has expired, false otherwise.GridCacheFlagException - If flags validation failed.void unlock(K key, GridPredicate<GridCacheEntry<K,V>>... filter) throws GridException
GridCacheTxConcurrency.PESSIMISTIC concurrency control for transaction
which will acquire explicit locks for relevant cache operations.
GridCacheFlag.LOCAL, GridCacheFlag.READ.key - Key to unlock.filter - Optional filter that needs to pass prior to unlock taking effect.GridException - If unlock execution resulted in error.GridCacheFlagException - If flags validation failed.void unlockAll(@Nullable Collection<? extends K> keys, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter) throws GridException
GridCacheTxConcurrency.PESSIMISTIC concurrency control for transaction
which will acquire explicit locks for relevant cache operations.
GridCacheFlag.LOCAL, GridCacheFlag.READ.keys - Keys to unlock.filter - Optional filter which needs to pass for individual entries
to be unlocked.GridException - If unlock execution resulted in error.GridCacheFlagException - If flags validation failed.boolean isLocked(K key)
This is a local in-VM operation and does not involve any network trips or access to persistent storage in any way.
key - Key to check.True if lock is owned by some node.boolean isLockedByThread(K key)
This is a local in-VM operation and does not involve any network trips or access to persistent storage in any way.
key - Key to check.True if key is locked by current thread.int size()
GridCache projection. It is essentially the
size of cache key set and is semantically identical to {GridCache.keySet().size().int nearSize()
null values and has O(1) complexity on base cache projection.
Note that for LOCAL caches this method will always return 0
0 if cache is not GridCacheMode.PARTITIONED.int primarySize()
GridCacheMode.LOCAL mode,
this method is identical to size().
For GridCacheMode.PARTITIONED and GridCacheMode.REPLICATED modes, this method will
return number of primary entries in the cache (excluding any backups). The complexity of this method
is O(P), where P is the total number of partitions.
@Nullable V promote(K key) throws GridException
GridCacheFlag.SKIP_SWAP, GridCacheFlag.READ.key - Key to promote entry for.null for non-existing key.GridException - If promote failed.GridCacheFlagException - If flags validation failed.void promoteAll(@Nullable Collection<? extends K> keys) throws GridException
GridCacheFlag.SKIP_SWAP, GridCacheFlag.READ.keys - Keys to promote entries for.GridException - If promote failed.GridCacheFlagException - If flags validation failed.Copyright © 2014. All rights reserved.