org.infinispan.loaders
Interface CacheStore

All Superinterfaces:
CacheLoader
All Known Implementing Classes:
AbstractCacheStore, AbstractDelegatingStore, AsyncStore, BdbjeCacheStore, BucketBasedCacheStore, CassandraCacheStore, ChainingCacheStore, CloudCacheStore, FileCacheStore, JdbcBinaryCacheStore, JdbcMixedCacheStore, JdbcStringBasedCacheStore, JdbmCacheStore, LockSupportCacheStore, ReadOnlyStore, RemoteCacheStore, SingletonStore

public interface CacheStore
extends CacheLoader

A specialization of the CacheLoader interface that can be written to.

Since:
4.0
Author:
Manik Surtani

Method Summary
 void clear()
          Clears all entries in the store
 void commit(GlobalTransaction tx)
          Commits a transaction that has been previously prepared.
 void fromStream(ObjectInput inputStream)
          Writes contents of the stream to the store.
 CacheStoreConfig getCacheStoreConfig()
          Returns the configuration object associated to this cache store config.
 void prepare(List<? extends Modification> modifications, GlobalTransaction tx, boolean isOnePhase)
          Issues a prepare call with a set of modifications to be applied to the cache store
 void purgeExpired()
          Purges expired entries from the store.
 boolean remove(Object key)
          Removes an entry in the store.
 void removeAll(Set<Object> keys)
          Bulk remove operation
 void rollback(GlobalTransaction tx)
          Rolls back a transaction that has been previously prepared

This method may be invoked on a transaction for which there is no prior prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean).

 void store(InternalCacheEntry entry)
          Stores an entry
 void toStream(ObjectOutput outputStream)
          Loads the entire state into a stream, using whichever format is most efficient for the cache loader implementation.
 
Methods inherited from interface org.infinispan.loaders.CacheLoader
containsKey, getConfigurationClass, init, load, load, loadAll, loadAllKeys, start, stop
 

Method Detail

store

void store(InternalCacheEntry entry)
           throws CacheLoaderException
Stores an entry

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

fromStream

void fromStream(ObjectInput inputStream)
                throws CacheLoaderException
Writes contents of the stream to the store. Implementations should expect that the stream contains data in an implementation-specific format, typically generated using toStream(java.io.ObjectOutput). While not a requirement, it is recommended that implementations make use of the StreamingMarshaller when dealing with the stream to make use of efficient marshalling.

It is imperative that implementations do not close the stream after finishing with it.

It is also recommended that implementations use their own start and end markers on the stream since other processes may write additional data to the stream after the cache store has written to it. As such, either markers or some other mechanism to prevent the store from reading too much information should be employed when writing to the stream in fromStream(java.io.ObjectInput) to prevent data corruption.

It can be assumed that the stream passed in already performs buffering such that the cache store implementation doesn't have to.

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

toStream

void toStream(ObjectOutput outputStream)
              throws CacheLoaderException
Loads the entire state into a stream, using whichever format is most efficient for the cache loader implementation. Typically read and parsed by fromStream(java.io.ObjectInput).

While not a requirement, it is recommended that implementations make use of the StreamingMarshaller when dealing with the stream to make use of efficient marshalling.

It is imperative that implementations do not flush or close the stream after finishing with it.

It is also recommended that implementations use their own start and end markers on the stream since other processes may write additional data to the stream after the cache store has written to it. As such, either markers or some other mechanism to prevent the store from reading too much information in fromStream(java.io.ObjectInput) should be employed, to prevent data corruption.

It can be assumed that the stream passed in already performs buffering such that the cache store implementation doesn't have to.

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

clear

void clear()
           throws CacheLoaderException
Clears all entries in the store

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

remove

boolean remove(Object key)
               throws CacheLoaderException
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

removeAll

void removeAll(Set<Object> keys)
               throws CacheLoaderException
Bulk remove operation

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

purgeExpired

void purgeExpired()
                  throws CacheLoaderException
Purges expired entries from the store.

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

prepare

void prepare(List<? extends Modification> modifications,
             GlobalTransaction tx,
             boolean isOnePhase)
             throws CacheLoaderException
Issues a prepare call with a set of modifications to be applied to the cache store

Parameters:
modifications - modifications to be applied
tx - transaction identifier
isOnePhase - if true, there will not be a commit or rollback phase and changes should be flushed immediately
Throws:
CacheLoaderException - in the event of problems writing to the store

commit

void commit(GlobalTransaction tx)
            throws CacheLoaderException
Commits a transaction that has been previously prepared.

This method may be invoked on a transaction for which there is no prior prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean). The implementation would need to deal with this case accordingly. Typically, this would be a no-op, after ensuring any resources attached to the transaction are cleared up.

Also note that this method may be invoked on a thread which is different from the prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean) invocation. As such, ThreadLocals should not be relied upon to maintain transaction context.

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

rollback

void rollback(GlobalTransaction tx)
Rolls back a transaction that has been previously prepared

This method may be invoked on a transaction for which there is no prior prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean). The implementation would need to deal with this case accordingly. Typically, this would be a no-op, after ensuring any resources attached to the transaction are cleared up.

Also note that this method may be invoked on a thread which is different from the prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean) invocation. As such, ThreadLocals should not be relied upon to maintain transaction context.

Parameters:
tx - tx to roll back

getCacheStoreConfig

CacheStoreConfig getCacheStoreConfig()
Returns the configuration object associated to this cache store config.


-->

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