org.infinispan.loaders.jdbm
Class JdbmCacheStore

java.lang.Object
  extended by org.infinispan.loaders.AbstractCacheLoader
      extended by org.infinispan.loaders.AbstractCacheStore
          extended by org.infinispan.loaders.jdbm.JdbmCacheStore
All Implemented Interfaces:
CacheLoader, CacheStore

@ThreadSafe
public class JdbmCacheStore
extends AbstractCacheStore

A persistent 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.

Author:
Elias Ross, Galder ZamarreƱo

Field Summary
 
Fields inherited from class org.infinispan.loaders.AbstractCacheStore
cache, marshaller, multiThreadedPurge, purgerService
 
Constructor Summary
JdbmCacheStore()
           
 
Method Summary
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()
           
 void init(CacheLoaderConfig clc, Cache cache, Marshaller m)
          Used to initialize a cache loader.
 InternalCacheEntry load(Object key)
          Loads an entry mapped to by a given key.
 Set<InternalCacheEntry> loadAll()
          Loads all entries in the loader.
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()
           
 
Methods inherited from class org.infinispan.loaders.AbstractCacheStore
commit, getCacheStoreConfig, getConcurrencyLevel, getMarshaller, prepare, purgeExpired, removeAll, rollback, safeClose, safeClose, supportsMultiThreadedPurge
 
Methods inherited from class org.infinispan.loaders.AbstractCacheLoader
containsKey
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.infinispan.loaders.CacheLoader
containsKey
 

Constructor Detail

JdbmCacheStore

public JdbmCacheStore()
Method Detail

getConfigurationClass

public Class<? extends CacheLoaderConfig> getConfigurationClass()
Returns:
the type of the CacheLoaderConfig bean used to configure this implementation of CacheLoader

init

public void init(CacheLoaderConfig clc,
                 Cache cache,
                 Marshaller m)
          throws CacheLoaderException
Description copied from interface: CacheLoader
Used to initialize a cache loader. Typically invoked by the CacheLoaderManager when setting up cache loaders.

Specified by:
init in interface CacheLoader
Overrides:
init in class AbstractCacheStore
Parameters:
clc - the cache loader configuration bean
cache - 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.
Throws:
CacheLoaderException

start

public void start()
           throws CacheLoaderException
Specified by:
start in interface CacheLoader
Overrides:
start in class AbstractCacheStore
Throws:
CacheLoaderException

load

public InternalCacheEntry load(Object key)
                        throws CacheLoaderException
Description copied from interface: CacheLoader
Loads an entry mapped to by a given key. Should return null if the entry does not exist. Expired entries are not returned.

Parameters:
key - key
Returns:
an entry
Throws:
CacheLoaderException - in the event of problems reading from source

loadAll

public Set<InternalCacheEntry> loadAll()
                                throws CacheLoaderException
Description copied from interface: CacheLoader
Loads all entries in the loader. Expired entries are not returned.

Returns:
a set of entries, or an empty set if the loader is emptied.
Throws:
CacheLoaderException - in the event of problems reading from source

stop

public void stop()
Closes all databases, ignoring exceptions, and nulls references to all database related information.

Specified by:
stop in interface CacheLoader
Overrides:
stop in class AbstractCacheStore

clear

public void clear()
           throws CacheLoaderException
Description copied from interface: CacheStore
Clears all entries in the store

Throws:
CacheLoaderException - in the event of problems writing to the store

remove

public boolean remove(Object key)
               throws CacheLoaderException
Description copied from interface: CacheStore
Removes an entry in the store.

Parameters:
key - key to remove
Returns:
true if the entry was removed; false if the entry wasn't found.
Throws:
CacheLoaderException - in the event of problems writing to the store

remove0

public boolean remove0(Object key)
                throws CacheLoaderException
Throws:
CacheLoaderException

store

public void store(InternalCacheEntry entry)
           throws CacheLoaderException
Description copied from interface: CacheStore
Stores an entry

Parameters:
entry - entry to store
Throws:
CacheLoaderException - in the event of problems writing to the store

toStream

public void toStream(ObjectOutput out)
              throws CacheLoaderException
Writes to a stream the number of entries (long) then the entries themselves.

Parameters:
out - stream to write to
Throws:
CacheLoaderException - in the event of problems reading from the store

fromStream

public void fromStream(ObjectInput in)
                throws CacheLoaderException
Reads from a stream the number of entries (long) then the entries themselves.

Parameters:
in - stream to read from
Throws:
CacheLoaderException - in the event of problems writing to the store

purgeInternal

protected void purgeInternal()
                      throws CacheLoaderException
Purge expired entries.

Specified by:
purgeInternal in class AbstractCacheStore
Throws:
CacheLoaderException

applyModifications

protected void applyModifications(List<? extends Modification> mods)
                           throws CacheLoaderException
Overrides:
applyModifications in class AbstractCacheStore
Throws:
CacheLoaderException

toString

public String toString()
Overrides:
toString in class Object

Google Analytics

Copyright © 2010 JBoss, a division of Red Hat. All Rights Reserved.