org.apache.jcs.auxiliary.disk.block
Class BlockDiskKeyStore<K extends Serializable>

java.lang.Object
  extended by org.apache.jcs.auxiliary.disk.block.BlockDiskKeyStore<K>

public class BlockDiskKeyStore<K extends Serializable>
extends Object

This is responsible for storing the keys.

Author:
Aaron Smuts

Nested Class Summary
 class BlockDiskKeyStore.LRUMap
          Class for recycling and lru.
 
Field Summary
protected  BlockDiskCache<K,?> blockDiskCache
          we need this so we can communicate free blocks to the data store when keys fall off the LRU
protected static org.apache.commons.logging.Log log
          The logger
protected  String logCacheName
          The name to prefix log messages with.
 
Constructor Summary
BlockDiskKeyStore(BlockDiskCacheAttributes cacheAttributes, BlockDiskCache<K,?> blockDiskCache)
          Set the configuration options.
 
Method Summary
protected  void clearMemoryMap()
          This is mainly used for testing.
 Set<Map.Entry<K,int[]>> entrySet()
          Gets the entry set.
 int[] get(K key)
          gets the object for the key.
 Set<K> keySet()
          Gets the key set.
protected  void loadKeys()
          Loads the keys from the .key file.
 void put(K key, int[] value)
          Puts a int[] in the keyStore.
 int[] remove(K key)
          Remove by key.
protected  void reset()
          Resets the file and creates a new key map.
protected  void saveKeys()
          Saves key file to disk.
 int size()
          Gets the size of the key hash.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.commons.logging.Log log
The logger


logCacheName

protected final String logCacheName
The name to prefix log messages with.


blockDiskCache

protected final BlockDiskCache<K extends Serializable,?> blockDiskCache
we need this so we can communicate free blocks to the data store when keys fall off the LRU

Constructor Detail

BlockDiskKeyStore

public BlockDiskKeyStore(BlockDiskCacheAttributes cacheAttributes,
                         BlockDiskCache<K,?> blockDiskCache)
Set the configuration options.

Parameters:
cacheAttributes -
blockDiskCache - used for freeing
Method Detail

saveKeys

protected void saveKeys()
Saves key file to disk. This gets the LRUMap entry set and write the entries out one by one after putting them in a wrapper.


reset

protected void reset()
Resets the file and creates a new key map.


clearMemoryMap

protected void clearMemoryMap()
This is mainly used for testing. It leave the disk in tact, and just clears memory.


loadKeys

protected void loadKeys()
Loads the keys from the .key file. The keys are stored individually on disk. They are added one by one to an LRUMap..


entrySet

public Set<Map.Entry<K,int[]>> entrySet()
Gets the entry set.

Returns:
entry set.

keySet

public Set<K> keySet()
Gets the key set.

Returns:
key set.

size

public int size()
Gets the size of the key hash.

Returns:
the number of keys.

get

public int[] get(K key)
gets the object for the key.

Parameters:
key -
Returns:
Object

put

public void put(K key,
                int[] value)
Puts a int[] in the keyStore.

Parameters:
key -
value -

remove

public int[] remove(K key)
Remove by key.

Parameters:
key -
Returns:
BlockDiskElementDescriptor if it was present, else null


Copyright © 2002-2013 The Apache Software Foundation. All Rights Reserved.