@ThreadSafe public class JdbmCacheStore extends AbstractCacheStore
CacheLoader
based on the JDBM project. See http://jdbm.sourceforge.net/ . Does not support
transaction isolation.
Supports removal of expired entries.
It would probably be better if meta-data (expiry time) was stored independent of the value of the entry. That is, if
(key,"m") == meta and (key,"v") == value.multiThreadedPurge, purgerService
cache, marshaller
Constructor and Description |
---|
JdbmCacheStore() |
Modifier and Type | Method and Description |
---|---|
protected void |
applyModifications(List<? extends Modification> mods) |
void |
clear()
Clears all entries in the store
|
void |
fromStream(ObjectInput in)
Reads from a stream the number of entries (long) then the entries themselves.
|
Class<? extends CacheLoaderConfig> |
getConfigurationClass()
This method is used by the configuration parser to get a hold of the CacheLoader implementation's corresponding
CacheLoaderConfig type. |
void |
init(CacheLoaderConfig clc,
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.
|
protected void |
purgeInternal()
Purge expired entries.
|
boolean |
remove(Object key)
Removes an entry in the store.
|
boolean |
remove0(Object key) |
void |
start() |
void |
stop()
Closes all databases, ignoring exceptions, and nulls references to all database related information.
|
void |
store(InternalCacheEntry entry)
Stores an entry
|
void |
toStream(ObjectOutput out)
Writes to a stream the number of entries (long) then the entries themselves.
|
String |
toString() |
commit, getCacheStoreConfig, getConcurrencyLevel, getMarshaller, prepare, purgeExpired, removeAll, rollback, safeClose, safeClose, supportsMultiThreadedPurge
containsKey
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
containsKey
public Class<? extends CacheLoaderConfig> getConfigurationClass()
CacheLoader
CacheLoaderConfig
type. This is usually done by instantiating the CacheLoader
and then calling this method. This may result in 2 instances being created, however, since the instance
created to get a hold of the configuration type is then discarded and another instance is created for actual
use as a CacheLoader when the cache starts.
Since Infinispan 4.1, you can also annotate your CacheLoader implementation with CacheLoaderMetadata
and provide this information via the annotation, which will prevent unnecessary instances being created.
CacheLoaderConfig
bean used to configure this
implementation of CacheLoader
.public void init(CacheLoaderConfig clc, Cache<?,?> cache, StreamingMarshaller m) throws CacheLoaderException
CacheLoader
CacheLoaderManager
when setting up cache loaders.init
in interface CacheLoader
init
in class AbstractCacheStore
clc
- 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 void start() throws CacheLoaderException
start
in interface CacheLoader
start
in class AbstractCacheStore
CacheLoaderException
public InternalCacheEntry load(Object key) throws CacheLoaderException
CacheLoader
key
- keyCacheLoaderException
- in the event of problems reading from sourcepublic Set<InternalCacheEntry> loadAll() throws CacheLoaderException
CacheLoader
CacheLoaderException
- in the event of problems reading from sourcepublic Set<InternalCacheEntry> load(int numEntries) throws CacheLoaderException
CacheLoader
numEntries
- maximum number of entries to loadCacheLoaderException
public Set<Object> loadAllKeys(Set<Object> keysToExclude) throws CacheLoaderException
CacheLoader
keysToExclude
- a set of keys to exclude. An empty set or null will indicate that all keys should be returned.CacheLoaderException
public void stop() throws CacheLoaderException
stop
in interface CacheLoader
stop
in class AbstractCacheStore
CacheLoaderException
public void clear() throws CacheLoaderException
CacheStore
CacheLoaderException
- in the event of problems writing to the storepublic boolean remove(Object key) throws CacheLoaderException
CacheStore
key
- key to removeCacheLoaderException
- in the event of problems writing to the storepublic boolean remove0(Object key) throws CacheLoaderException
CacheLoaderException
public void store(InternalCacheEntry entry) throws CacheLoaderException
CacheStore
entry
- entry to storeCacheLoaderException
- in the event of problems writing to the storepublic void toStream(ObjectOutput out) throws CacheLoaderException
out
- stream to write toCacheLoaderException
- in the event of problems reading from the storepublic void fromStream(ObjectInput in) throws CacheLoaderException
in
- stream to read fromCacheLoaderException
- in the event of problems writing to the storeprotected void purgeInternal() throws CacheLoaderException
purgeInternal
in class AbstractCacheStore
CacheLoaderException
protected void applyModifications(List<? extends Modification> mods) throws CacheLoaderException
applyModifications
in class AbstractCacheStore
CacheLoaderException
Copyright © 2017 JBoss, a division of Red Hat. All Rights Reserved.