Class BerkeleyDBBinaryStore

All Implemented Interfaces:
BinaryStore

public class BerkeleyDBBinaryStore extends AbstractBinaryStore
An implementation of the BinaryStore interface using Sleepycat Berkeley DB Java Edition.
Author:
mf 2005.09.29
See Also:
  • Field Details

  • Constructor Details

    • BerkeleyDBBinaryStore

      public BerkeleyDBBinaryStore(String sDbName, DatabaseFactory dbFactory) throws com.sleepycat.je.DatabaseException
      Create a new Berkeley DB BinaryStore using the supplied DatabaseFactory.
      Parameters:
      sDbName - the name of the table to store the cache's data in, null indicates a temporary table name.
      dbFactory - the factory to use to create the Database
      Throws:
      com.sleepycat.je.DatabaseException - if the Database creation failed
  • Method Details

    • init

      protected void init(String sDbName, DatabaseFactory dbFactory) throws com.sleepycat.je.DatabaseException
      Initialize the BinaryStore.
      Parameters:
      sDbName - the name of the table to store the cache's data in, null indicates a temporary table name.
      dbFactory - the factory to use to create the Database
      Throws:
      com.sleepycat.je.DatabaseException - if the Database creation failed
    • toString

      public String toString()
      Return a human readable description of the BinaryStore.
      Overrides:
      toString in class Object
      Returns:
      a human readable description of the BinaryStore
    • load

      public Binary load(Binary binKey)
      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 BinaryStore
      Specified by:
      load in class AbstractBinaryStore
      Parameters:
      binKey - 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(Binary binKey, Binary binValue)
      Store the specified value under the specific key in the underlying store.

      This method is supports both key/value creation and value update for a specific key.

      Specified by:
      store in interface BinaryStore
      Overrides:
      store in class AbstractBinaryStore
      Parameters:
      binKey - key to store the value under
      binValue - value to be stored
    • erase

      public void erase(Binary binKey)
      Remove the specified key from the underlying store if present.
      Specified by:
      erase in interface BinaryStore
      Overrides:
      erase in class AbstractBinaryStore
      Parameters:
      binKey - key whose mapping is to be removed from the map
    • eraseAll

      public void eraseAll()
      Remove all data from the underlying store.
      Specified by:
      eraseAll in interface BinaryStore
      Overrides:
      eraseAll in class AbstractBinaryStore
    • keys

      public Iterator keys()
      Iterate all keys in the underlying store.
      Specified by:
      keys in interface BinaryStore
      Overrides:
      keys in class AbstractBinaryStore
      Returns:
      a read-only iterator of the keys in the underlying store
    • close

      public void close()
      Close the BinaryStore.
    • getDbHolder

      Get the DatabaseHolder. To prevent the underlying Database from being deleted during usage, hold onto this handle while using the Database object.
      Returns:
      the DatabaseHolder
    • getFactory

      public DatabaseFactory getFactory()
      Get the DatabaseFactory used to create the underlying Database.
      Returns:
      the DatabaseFactory