Class BinaryStoreCacheStore<K,V>

All Implemented Interfaces:
CacheLoader<K,V>, CacheStore<K,V>, IterableCacheLoader<K,V>

public class BinaryStoreCacheStore<K,V> extends AbstractCacheStore<K,V> implements CacheStore<K,V>, IterableCacheLoader<K,V>
A CacheStore that sits directly on top of a BinaryStore.
Since:
Coherence 2.5
Author:
cp 2004.09.24
  • Constructor Details

    • BinaryStoreCacheStore

      public BinaryStoreCacheStore(BinaryStore store)
      Create a CacheStore that delegates to a BinaryStore.
      Parameters:
      store - the BinaryStore to use to write the serialized objects to
    • BinaryStoreCacheStore

      public BinaryStoreCacheStore(BinaryStore store, ClassLoader loader)
      Create a CacheStore that delegates to a BinaryStore, using the passed ClassLoader for deserialization.
      Parameters:
      store - the BinaryStore to use to write the serialized objects to
      loader - the ClassLoader to use for deserialization
    • BinaryStoreCacheStore

      public BinaryStoreCacheStore(BinaryStore store, boolean fBinaryOnly)
      Create a CacheStore that delegates to a BinaryStore, optionally storing only Binary keys and values.
      Parameters:
      store - the BinaryStore to use to write the serialized objects to
      fBinaryOnly - true indicates that this CacheStore will only manage binary keys and values
  • Method Details

    • load

      public V load(K key)
      Return the value associated with the specified key, or null if the key does not have an associated value in the underlying store.
      Specified by:
      load in interface CacheLoader<K,V>
      Specified by:
      load in class AbstractCacheLoader<K,V>
      Parameters:
      key - key whose associated value is to be returned
      Returns:
      the value associated with the specified key, or null if no value is available for that key
    • store

      public void store(K key, V value)
      Store the specified value under the specified key in the underlying store. This method is intended to support both key/value creation and value update for a specific key.
      Specified by:
      store in interface CacheStore<K,V>
      Overrides:
      store in class AbstractCacheStore<K,V>
      Parameters:
      key - key to store the value under
      value - value to be stored
      Throws:
      UnsupportedOperationException - if this implementation or the underlying store is read-only
    • erase

      public void erase(K key)
      Remove the specified key from the underlying store if present.
      Specified by:
      erase in interface CacheStore<K,V>
      Overrides:
      erase in class AbstractCacheStore<K,V>
      Parameters:
      key - key to remove from the store
      Throws:
      UnsupportedOperationException - if this implementation or the underlying store is read-only
    • keys

      public Iterator<K> keys()
      Iterate all keys in the underlying store.
      Specified by:
      keys in interface IterableCacheLoader<K,V>
      Returns:
      a read-only iterator of the keys in the underlying store
      Throws:
      UnsupportedOperationException - if the underlying store is not iterable
    • toBinary

      protected Binary toBinary(Object o)
      Translate the passed Object object into an Binary object.
      Parameters:
      o - the Object to serialize into a Binary object
      Returns:
      the Binary object
    • fromBinary

      protected Object fromBinary(Binary bin)
      Translate the passed Binary object into an Object object.
      Parameters:
      bin - the Binary object to deserialize
      Returns:
      the deserialized object
    • getBinaryStore

      public BinaryStore getBinaryStore()
      Returns the BinaryStore that this CacheStore uses for its storage.
      Returns:
      the BinaryStore that this CacheStore uses
    • setBinaryStore

      protected void setBinaryStore(BinaryStore store)
      Configures the BinaryStore that this CacheStore will use for its storage.
      Parameters:
      store - the BinaryStore to use
    • getClassLoader

      public ClassLoader getClassLoader()
      Returns the ClassLoader that this CacheStore uses for deserialization, if it has one.
      Returns:
      the ClassLoader that this CacheStore uses for deserialization; may be null
    • setClassLoader

      protected void setClassLoader(ClassLoader loader)
      Configure the ClassLoader that this CacheStore will use for deserialization.
      Parameters:
      loader - the ClassLoader that this CacheStore should use for deserialization
    • isBinaryOnly

      public boolean isBinaryOnly()
      Determine if the keys and values in this CacheStore are known to be all Binary.
      Returns:
      true if all keys and values will be Binary to start with, and thus will not require conversion