org.apache.jcs.auxiliary.disk.block
Class BlockDiskKeyStore

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

public class BlockDiskKeyStore
extends Object

This is responsible for storing the keys.

Author:
Aaron Smuts

Nested Class Summary
 class BlockDiskKeyStore.LRUMap
          Class for recylcing and lru.
 
Constructor Summary
BlockDiskKeyStore(BlockDiskCacheAttributes cacheAttributes, BlockDiskCache blockDiskCache)
          Set the configuration options.
 
Method Summary
protected  void clearMemoryMap()
          This is mainly used for testing.
 Set entrySet()
          Gets the entry set.
 int[] get(Object key)
          gets the object for the key.
 Set keySet()
          Gets the key set.
protected  void loadKeys()
          Loads the keys from the .key file.
 void put(Object key, int[] value)
          Puts a int[] in the keyStore.
 int[] remove(Object 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
 

Constructor Detail

BlockDiskKeyStore

public BlockDiskKeyStore(BlockDiskCacheAttributes cacheAttributes,
                         BlockDiskCache blockDiskCache)
                  throws Exception
Set the configuration options.

Parameters:
cacheAttributes -
blockDiskCache - used for freeing
Throws:
Exception
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()
                 throws InterruptedException
Loads the keys from the .key file. The keys are stored individually on disk. They are added one by one to an LRUMap..

Throws:
InterruptedException

entrySet

public Set entrySet()
Gets the entry set.

Returns:
entry set.

keySet

public Set 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(Object key)
gets the object for the key.

Parameters:
key -
Returns:
Object

put

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

Parameters:
key -
value -

remove

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

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


Copyright © 2002-2012 Apache Software Foundation. All Rights Reserved.