public class AsyncStore extends AbstractDelegatingStore
<async enabled="true" />
to define whether cache loader operations are to be asynchronous. If not specified, a cache loader operation is
assumed synchronous and this decorator is not applied.
Write operations affecting same key are now coalesced so that only the final state is actually stored.
Constructor and Description |
---|
AsyncStore(CacheStore delegate,
AsyncStoreConfig asyncStoreConfig) |
Modifier and Type | Method and Description |
---|---|
protected void |
applyModificationsSync(List<Modification> mods) |
void |
clear()
Clears all entries in the store
|
void |
commit(GlobalTransaction tx)
Commits a transaction that has been previously prepared.
|
boolean |
containsKey(Object key) |
void |
init(CacheLoaderConfig config,
Cache<?,?> cache,
StreamingMarshaller m)
Used to initialize a cache loader.
|
Set<InternalCacheEntry> |
load(int numEntries)
Loads up to a specific number of entries.
|
InternalCacheEntry |
load(Object key)
Loads an entry mapped to by a given key.
|
Set<InternalCacheEntry> |
loadAll()
Loads all entries in the loader.
|
Set<Object> |
loadAllKeys(Set<Object> keysToExclude)
Loads a set of all keys, excluding a filter set.
|
void |
prepare(List<? extends Modification> mods,
GlobalTransaction tx,
boolean isOnePhase)
Issues a prepare call with a set of modifications to be applied to the cache store
|
boolean |
remove(Object key)
Removes an entry in the store.
|
void |
removeAll(Set<Object> keys)
Bulk remove operation
|
void |
rollback(GlobalTransaction tx)
Rolls back a transaction that has been previously prepared
This method may be invoked on a transaction for which there is no prior
CacheStore.prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean) . |
void |
start() |
void |
stop() |
void |
store(InternalCacheEntry entry)
Stores an entry
|
fromStream, getCacheStoreConfig, getConfigurationClass, getDelegate, purgeExpired, setDelegate, toStream, undelegateCacheLoader
public AsyncStore(CacheStore delegate, AsyncStoreConfig asyncStoreConfig)
public void init(CacheLoaderConfig config, Cache<?,?> cache, StreamingMarshaller m) throws CacheLoaderException
CacheLoader
org.infinispan.loaders.CacheLoaderManager
when setting up cache loaders.init
in interface CacheLoader
init
in class AbstractDelegatingStore
config
- the cache loader configuration beancache
- cache associated with this cache loader. Implementations may use this to determine cache name when
selecting where refer to state in storage, for example, a different database table name.m
- marshaller to use when loading state from a stream, if supported by the implementation.CacheLoaderException
public InternalCacheEntry load(Object key) throws CacheLoaderException
CacheLoader
load
in interface CacheLoader
load
in class AbstractDelegatingStore
key
- keyCacheLoaderException
- in the event of problems reading from sourcepublic boolean containsKey(Object key) throws CacheLoaderException
containsKey
in interface CacheLoader
containsKey
in class AbstractDelegatingStore
key
- key to testCacheLoaderException
- in the event of problems reading from sourcepublic Set<Object> loadAllKeys(Set<Object> keysToExclude) throws CacheLoaderException
CacheLoader
loadAllKeys
in interface CacheLoader
loadAllKeys
in class AbstractDelegatingStore
keysToExclude
- a set of keys to exclude. An empty set or null will indicate that all keys should be returned.CacheLoaderException
public Set<InternalCacheEntry> loadAll() throws CacheLoaderException
CacheLoader
loadAll
in interface CacheLoader
loadAll
in class AbstractDelegatingStore
CacheLoaderException
- in the event of problems reading from sourcepublic Set<InternalCacheEntry> load(int numEntries) throws CacheLoaderException
CacheLoader
load
in interface CacheLoader
load
in class AbstractDelegatingStore
numEntries
- maximum number of entries to loadCacheLoaderException
public void store(InternalCacheEntry entry)
CacheStore
store
in interface CacheStore
store
in class AbstractDelegatingStore
entry
- entry to storepublic void clear()
CacheStore
clear
in interface CacheStore
clear
in class AbstractDelegatingStore
public boolean remove(Object key)
CacheStore
remove
in interface CacheStore
remove
in class AbstractDelegatingStore
key
- key to removepublic void removeAll(Set<Object> keys) throws CacheLoaderException
CacheStore
removeAll
in interface CacheStore
removeAll
in class AbstractDelegatingStore
keys
- to removeCacheLoaderException
- in the event of problems writing to the storepublic void prepare(List<? extends Modification> mods, GlobalTransaction tx, boolean isOnePhase) throws CacheLoaderException
CacheStore
prepare
in interface CacheStore
prepare
in class AbstractDelegatingStore
mods
- modifications to be appliedtx
- transaction identifierisOnePhase
- if true, there will not be a commit or rollback phase and changes should be flushed
immediatelyCacheLoaderException
- in the event of problems writing to the storepublic void rollback(GlobalTransaction tx)
CacheStore
CacheStore.prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean)
. The implementation would
need to deal with this case accordingly. Typically, this would be a no-op, after ensuring any resources attached
to the transaction are cleared up.
Also note that this method may be invoked on a thread which is different from the CacheStore.prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean)
invocation. As such, ThreadLocal
s should not be relied upon to maintain transaction context.
rollback
in interface CacheStore
rollback
in class AbstractDelegatingStore
tx
- tx to roll backpublic void commit(GlobalTransaction tx) throws CacheLoaderException
CacheStore
CacheStore.prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean)
. The implementation would
need to deal with this case accordingly. Typically, this would be a no-op, after ensuring any resources attached
to the transaction are cleared up.
Also note that this method may be invoked on a thread which is different from the CacheStore.prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean)
invocation. As such, ThreadLocal
s should not be relied upon to maintain transaction context.
commit
in interface CacheStore
commit
in class AbstractDelegatingStore
tx
- tx to commitCacheLoaderException
- in the event of problems writing to the storepublic void start() throws CacheLoaderException
start
in interface CacheLoader
start
in class AbstractDelegatingStore
CacheLoaderException
public void stop() throws CacheLoaderException
stop
in interface CacheLoader
stop
in class AbstractDelegatingStore
CacheLoaderException
protected void applyModificationsSync(List<Modification> mods) throws CacheLoaderException
CacheLoaderException
Copyright © 2014 JBoss, a division of Red Hat. All Rights Reserved.