Package org.infinispan.persistence.spi
Interface CacheLoader<K,V>
-
- All Superinterfaces:
Lifecycle
- All Known Subinterfaces:
AdvancedCacheLoader<K,V>
,AdvancedLoadWriteStore<K,V>
,ExternalStore<K,V>
,FlagAffectedStore<K,V>
,SegmentedAdvancedLoadWriteStore<K,V>
- All Known Implementing Classes:
AbstractSegmentedAdvancedLoadWriteStore
,AdvancedAsyncCacheLoader
,AsyncCacheLoader
,ClusterLoader
,ComposedSegmentedLoadWriteStore
,DelegatingCacheLoader
,JdbcStringBasedStore
,JpaStore
,RemoteStore
,RestStore
,RocksDBStore
,SingleFileStore
,SoftIndexFileStore
@ThreadSafe public interface CacheLoader<K,V> extends Lifecycle
Defines the logic for loading data from an external storage. The writing of data is optional and coordinated through aCacheWriter
.- Since:
- 6.0
- Author:
- Mircea Markus
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description boolean
contains(java.lang.Object key)
Returns true if the storage contains an entry associated with the given key.void
init(InitializationContext ctx)
Used to initialize a cache loader.default boolean
isAvailable()
default MarshalledEntry<K,V>
load(java.lang.Object key)
Deprecated.since 10.0 please implement {loadEntry(Object)
} insteaddefault MarshallableEntry<K,V>
loadEntry(java.lang.Object key)
Fetches an entry from the storage.
-
-
-
Method Detail
-
init
void init(InitializationContext ctx)
Used to initialize a cache loader. Typically invoked by thePersistenceManager
when setting up cache loaders.- Throws:
PersistenceException
- in case of an error, e.g. communicating with the external storage
-
load
@Deprecated default MarshalledEntry<K,V> load(java.lang.Object key)
Deprecated.since 10.0 please implement {loadEntry(Object)
} insteadFetches an entry from the storage. If aMarshalledEntry
needs to be created here,InitializationContext.getMarshalledEntryFactory()
andInitializationContext.getByteBufferFactory()
should be used.- Returns:
- the entry, or null if the entry does not exist
- Throws:
PersistenceException
- in case of an error, e.g. communicating with the external storage
-
loadEntry
default MarshallableEntry<K,V> loadEntry(java.lang.Object key)
Fetches an entry from the storage. If aMarshallableEntry
needs to be created here,InitializationContext.getMarshallableEntryFactory()
()} andInitializationContext.getByteBufferFactory()
should be used.- Returns:
- the entry, or null if the entry does not exist
- Throws:
PersistenceException
- in case of an error, e.g. communicating with the external storage
-
contains
boolean contains(java.lang.Object key)
Returns true if the storage contains an entry associated with the given key.- Throws:
PersistenceException
- in case of an error, e.g. communicating with the external storage
-
isAvailable
default boolean isAvailable()
- Returns:
- true if the writer can be connected to, otherwise false
-
-