public interface CacheStore<K,V> extends javax.cache.integration.CacheLoader<K,V>, javax.cache.integration.CacheWriter<K,V>
CacheConfiguration.getCacheStoreFactory()
configuration property. If not provided, values will be only kept in cache memory
or swap storage without ever being persisted to a persistent storage.
CacheStoreAdapter
provides default implementation for bulk operations,
such as CacheLoader.loadAll(Iterable)
,
CacheWriter.writeAll(Collection)
, and CacheWriter.deleteAll(Collection)
by sequentially calling corresponding CacheLoader.load(Object)
,
CacheWriter.write(javax.cache.Cache.Entry)
, and CacheWriter.delete(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.
Provided implementations may be used for test purposes:
org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStore
CacheJdbcBlobStore
All transactional operations of this API are provided with ongoing Transaction
,
if any. You can attach any metadata to it, e.g. to recognize if several operations belong
to the same transaction or not.
Here is an example of how attach a JDBC connection as transaction metadata:
Connection conn = tx.meta("some.name"); if (conn == null) { conn = ...; // Get JDBC connection. // Store connection in transaction metadata, so it can be accessed // for other operations on the same transaction. tx.addMeta("some.name", conn); }
CacheStoreSession
Modifier and Type | Method and Description |
---|---|
void |
loadCache(IgniteBiInClosure<K,V> clo,
Object... args)
Loads all values from underlying persistent storage.
|
void |
sessionEnd(boolean commit)
Deprecated.
Use
CacheStoreSessionListener instead (refer to its JavaDoc for details). |
void loadCache(IgniteBiInClosure<K,V> clo, @Nullable Object... args) throws javax.cache.integration.CacheLoaderException
IgniteCache.loadCache(IgniteBiPredicate, Object...)
method is invoked which is usually to preload the cache from persistent storage.
This method is optional, and cache implementation does not depend on this
method to do anything. Default implementation of this method in
CacheStoreAdapter
does nothing.
For every loaded value method IgniteBiInClosure.apply(Object, Object)
should be called on the passed in closure. The closure will then make sure
that the loaded value is stored in cache.
clo
- Closure for loaded values.args
- Arguments passes into
IgniteCache.loadCache(IgniteBiPredicate, Object...)
method.javax.cache.integration.CacheLoaderException
- If loading failed.@Deprecated void sessionEnd(boolean commit) throws javax.cache.integration.CacheWriterException
CacheStoreSessionListener
instead (refer to its JavaDoc for details).'commit'
parameter.commit
- True
if transaction should commit, false
for rollback.javax.cache.integration.CacheWriterException
- If commit or rollback failed. Note that commit failure in some cases
may bring cache transaction into TransactionState.UNKNOWN
which will
consequently cause all transacted entries to be invalidated.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.16.0 Release Date : December 15 2023