public class AsyncCacheLoader extends AbstractDelegatingCacheLoader
<attribute name="CacheLoaderAsynchronous">true</attribute>
to define whether cache loader operations are to be asynchronous. If not
specified, a cache loader operation is assumed synchronous.
The following additional parameters are available:
true
, this loader returns the old values from put(org.jboss.cache.Fqn, java.lang.Object, java.lang.Object)
and remove(org.jboss.cache.Fqn, java.lang.Object)
methods. Otherwise, these methods always return
null. Default is true. false
improves the performance of these
operations.put(org.jboss.cache.Fqn, java.lang.Object, java.lang.Object)
operations will be processed
synchronously, and then only the remove(org.jboss.cache.Fqn, java.lang.Object)
operations will be
processed asynchronously. This mode may be useful for processing
expiration of messages within a separate thread and keeping other
operations synchronous for reliability.
cache.async.batchSize
and
cache.async.pollWait
. For larger sized records, use a smaller
value for cache.async.queueSize
.buddyFqnTransformer, cache, regionManager, transactions
Constructor and Description |
---|
AsyncCacheLoader() |
AsyncCacheLoader(CacheLoader cacheLoader) |
Modifier and Type | Method and Description |
---|---|
void |
commit(Object tx)
TODO this is the same as the AbstractCacheLoader.
|
Map |
get(Fqn name)
Returns all keys and values from the persistent store, given a
Fqn |
void |
prepare(Object tx,
List<Modification> modifications,
boolean one_phase)
TODO this is the same as the AbstractCacheLoader.
|
void |
put(Fqn name,
Map attributes)
Puts all entries of the map into the existing map of the given node,
overwriting existing keys, but not clearing the existing map before
insertion.
|
Object |
put(Fqn name,
Object key,
Object value)
Puts a key and value into the attribute map of a given node.
|
void |
put(List<Modification> modifications)
Applies all modifications to the backend store.
|
void |
remove(Fqn name)
Removes the given node and all its subnodes, does nothing if the node does not exist.
|
Object |
remove(Fqn name,
Object key)
Removes the given key and value from the attributes of the given node.
|
void |
removeData(Fqn name)
Removes all attributes from a given node, but doesn't delete the node
itself or any subnodes.
|
void |
rollback(Object tx)
TODO this is the same as the AbstractCacheLoader.
|
void |
setConfig(CacheLoaderConfig.IndividualCacheLoaderConfig base)
Sets the configuration.
|
void |
start() |
void |
stop() |
String |
toString() |
create, destroy, exists, getCacheLoader, getChildrenNames, getConfig, loadEntireState, loadState, setCache, setCacheLoader, setRegionManager, storeEntireState, storeState
doMarshall, doUnmarshall, getMarshaller, getNodeDataList, loadStateHelper, move, put, regionAwareMarshall, regionAwareUnmarshall, storeStateHelper
public AsyncCacheLoader()
public AsyncCacheLoader(CacheLoader cacheLoader)
public void setConfig(CacheLoaderConfig.IndividualCacheLoaderConfig base)
CacheLoader
Lifecycle.create()
and Lifecycle.start()
.setConfig
in interface CacheLoader
setConfig
in class AbstractDelegatingCacheLoader
base
- May be an instance of the CacheLoaderConfig.IndividualCacheLoaderConfig
base
class, in which case the cache loader should use the
PluggableConfigurationComponent.getProperties()
method to find configuration information. Alternatively,
may be a type-specific subclass of CacheLoaderConfig.IndividualCacheLoaderConfig
,
if there is one.public Map get(Fqn name) throws Exception
CacheLoader
Fqn
get
in interface CacheLoader
get
in class AbstractDelegatingCacheLoader
name
- the Fqn
to search for.Exception
public void prepare(Object tx, List<Modification> modifications, boolean one_phase) throws Exception
prepare
in interface CacheLoader
prepare
in class AbstractDelegatingCacheLoader
tx
- The transaction, indended to be used by implementations as an identifier of the transaction (and not necessarily a JTA Transaction
object)modifications
- A List
containing Modification
s, for the given transactionone_phase
- Persist immediately and (for example) commit the local JDBC transaction as well. When true,
we won't get a CacheLoader.commit(Object)
or CacheLoader.rollback(Object)
method call laterException
public void commit(Object tx) throws Exception
commit
in interface CacheLoader
commit
in class AbstractDelegatingCacheLoader
tx
- transaction to commitException
public void rollback(Object tx)
rollback
in interface CacheLoader
rollback
in class AbstractDelegatingCacheLoader
tx
- transaction to roll backpublic Object put(Fqn name, Object key, Object value) throws Exception
CacheLoader
put
in interface CacheLoader
put
in class AbstractDelegatingCacheLoader
Exception
public void put(Fqn name, Map attributes) throws Exception
CacheLoader
Map.putAll(java.util.Map<? extends K, ? extends V>)
.
If the node does not exist, all parent nodes from the root down are created automatically
Note since 3.0, as an optimization, this method will require a definitive attribute map and
not just a subset. This will allow cache loader implementations to overwrite rather than merge, if that is
deemed more efficient. This will not break backward compatibility since performing a merge will not cause
any loss of data even though it is an unnecessary step.put
in interface CacheLoader
put
in class AbstractDelegatingCacheLoader
name
- The fully qualified name of the nodeattributes
- A Map of attributes. Can be nullException
public void put(List<Modification> modifications) throws Exception
CacheLoader
put
in interface CacheLoader
put
in class AbstractDelegatingCacheLoader
modifications
- A ListException
public Object remove(Fqn name, Object key) throws Exception
CacheLoader
remove
in interface CacheLoader
remove
in class AbstractDelegatingCacheLoader
Exception
public void remove(Fqn name) throws Exception
CacheLoader
remove
in interface CacheLoader
remove
in class AbstractDelegatingCacheLoader
name
- the Fqn
of the nodeException
public void removeData(Fqn name) throws Exception
CacheLoader
removeData
in interface CacheLoader
removeData
in class AbstractDelegatingCacheLoader
name
- the Fqn
of the nodeException
public void start() throws Exception
start
in interface Lifecycle
start
in class AbstractDelegatingCacheLoader
Exception
public void stop()
stop
in interface Lifecycle
stop
in class AbstractDelegatingCacheLoader
Copyright © 2012 JBoss, a division of Red Hat. All Rights Reserved.