public abstract class GridCacheStoreAdapter<K,V> extends Object implements GridCacheStore<K,V>
loadAll(GridCacheTx, Collection, GridBiInClosure),
putAll(GridCacheTx, Map), abd removeAll(GridCacheTx, Collection)
by sequentially calling corresponding GridCacheStore.load(GridCacheTx, Object),
GridCacheStore.put(GridCacheTx, Object, Object), and GridCacheStore.remove(GridCacheTx, Object)
operations. Use this adapter whenever such behaviour is acceptable. However in many cases
it maybe more preferable to take advantage of database batch update functionality, and therefore
default adapter implementation may not be the best option.
Note that method loadCache(GridBiInClosure, Object...) has empty
implementation because it is essentially up to the user to invoke it with
specific arguments.
| Constructor and Description |
|---|
GridCacheStoreAdapter() |
| Modifier and Type | Method and Description |
|---|---|
void |
loadAll(GridCacheTx tx,
Collection<? extends K> keys,
GridBiInClosure<K,V> c)
Loads all values for given keys and passes every value to the provided closure.
|
void |
loadCache(GridBiInClosure<K,V> clo,
Object... args)
Default empty implementation.
|
void |
putAll(GridCacheTx tx,
Map<? extends K,? extends V> map)
Stores given key value pairs in persistent storage.
|
void |
removeAll(GridCacheTx tx,
Collection<? extends K> keys)
Removes all vales identified by given keys from persistent storage.
|
void |
txEnd(GridCacheTx tx,
boolean commit)
Default empty implementation for ending transactions.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitload, put, removepublic void loadCache(GridBiInClosure<K,V> clo, Object... args) throws GridException
GridCache.loadCache(GridBiPredicate, long, Object...) method
is explicitly called.loadCache in interface GridCacheStore<K,V>clo - Closure for loaded values.args - Arguments passes into
GridCache.loadCache(GridBiPredicate, long, Object...) method.GridException - If loading failed.public void loadAll(@Nullable GridCacheTx tx, Collection<? extends K> keys, GridBiInClosure<K,V> c) throws GridException
For every loaded value method GridInClosure.apply(Object) should be called on
the passed in closure. The closure will then make sure that the loaded value is stored
in cache.
loadAll in interface GridCacheStore<K,V>tx - Cache transaction.keys - Collection of keys to load.c - Closure to call for every loaded element.GridException - If load failed.public void putAll(GridCacheTx tx, Map<? extends K,? extends V> map) throws GridException
null.putAll in interface GridCacheStore<K,V>tx - Cache transaction, if write-behind is not enabled, null otherwise.map - Values to store.GridException - If store failed.public void removeAll(GridCacheTx tx, Collection<? extends K> keys) throws GridException
null.removeAll in interface GridCacheStore<K,V>tx - Cache transaction, if write-behind is not enabled, null otherwise.keys - Keys to remove.GridException - If remove failed.public void txEnd(GridCacheTx tx, boolean commit) throws GridException
txEnd in interface GridCacheStore<K,V>tx - Cache transaction being ended.commit - True if transaction should commit, false for rollback.GridException - If commit or rollback failed. Note that commit failure in some cases
may bring cache transaction into GridCacheTxState.UNKNOWN which will
consequently cause all transacted entries to be invalidated.Copyright © 2014. All rights reserved.