org.shoal.ha.cache.api
Interface DataStore<K,V>

All Known Implementing Classes:
ReplicatedDataStore

public interface DataStore<K,V>

A DataStore allows (#{Serializable} / #{Storable}) objects to be placed in the cache. The cache itself is created and configured using a #{DataStoreFactory}.

Author:
Mahesh Kannan

Method Summary
 void close()
          Close this datastore.
 java.util.Collection find(DataStoreEntryEvaluator<K,V> evaluator)
          Finds / Retrieves values that satisfy a criteria as dictated by the evaluator.
 V get(K k)
          Returns the value to which the specified key is mapped in this cache.
 java.lang.String put(K k, V v)
          Creates or Replaces the object associated with key k.
 void remove(K k)
          Removes the mapping between the key and the object.
 int removeIdleEntries(long idleFor)
          Removes all entries that were not accessed for more than 'idlefor' millis
 java.lang.String touch(K k, long version, long timeStamp, long ttl)
          Updates the timestamp associated with this entry.
 void update(DataStoreEntryEvaluator<K,V> evaluator)
          Updates all existing values associated with a key using the evaluator.
 java.lang.String updateDelta(K k, V delta)
          Performs an incremental update of the value associated with this key.
 

Method Detail

put

java.lang.String put(K k,
                     V v)
                     throws DataStoreException
Creates or Replaces the object associated with key k.

Parameters:
k - The Key
v - The value. The value must be either serializable of the DataStoreEntryHelper that is associated with this cache must be able to transform this into a serializable.
Throws:
DataStoreException

get

V get(K k)
      throws DataStoreException
Returns the value to which the specified key is mapped in this cache.

Parameters:
k - The key
Returns:
The value if the association exists or null.
Throws:
DataStoreException

remove

void remove(K k)
            throws DataStoreException
Removes the mapping between the key and the object.

Parameters:
k - The key
Throws:
DataStoreException

touch

java.lang.String touch(K k,
                       long version,
                       long timeStamp,
                       long ttl)
                       throws DataStoreException
Updates the timestamp associated with this entry. see #{removeIdleEntries}

Parameters:
k - The key
Throws:
DataStoreException

updateDelta

java.lang.String updateDelta(K k,
                             V delta)
                             throws DataStoreException
Performs an incremental update of the value associated with this key. The DataStore's DataStoreEntryHelper.updateState() method will be called with the key, the DataStoreEnrty and the delta. If no value is associated with K, then a hollow DataStoreEntry will be passed to DataStoreEntryHelper.updateState().

Parameters:
k - The key
delta - The object whose eval() method will be called.
Throws:
DataStoreException
See Also:
#{DataStoreEntryEvaluator.eval}

find

java.util.Collection find(DataStoreEntryEvaluator<K,V> evaluator)
Finds / Retrieves values that satisfy a criteria as dictated by the evaluator. The evaluator's eval() method will be called with both the key and the existing value.

Parameters:
evaluator - The StoreEntryEvaluator whose eval() method will be called.
See Also:
#{DataStoreEntryEvaluator.eval}

update

void update(DataStoreEntryEvaluator<K,V> evaluator)
Updates all existing values associated with a key using the evaluator. The evaluator's eval() method will be called with both the key and the existing value.

Parameters:
evaluator - The StoreEntryEvaluator whose eval() method will be called.
See Also:
#{DataStoreEntryEvaluator.eval}

removeIdleEntries

int removeIdleEntries(long idleFor)
Removes all entries that were not accessed for more than 'idlefor' millis

Parameters:
idleFor - Time in milli seconds

close

void close()
Close this datastore. This causes all data to be removed(?)



Copyright © 2010. All Rights Reserved.