Class BlockDiskKeyStore<K>
java.lang.Object
org.apache.commons.jcs3.auxiliary.disk.block.BlockDiskKeyStore<K>
This is responsible for storing the keys.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassClass for recycling and lru.classClass for recycling and lru. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final BlockDiskCache<K,?> we need this so we can communicate free blocks to the data store when keys fall off the LRUprotected final StringThe name to prefix log messages with. -
Constructor Summary
ConstructorsConstructorDescriptionBlockDiskKeyStore(BlockDiskCacheAttributes cacheAttributes, BlockDiskCache<K, ?> blockDiskCache) Set the configuration options. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidThis is mainly used for testing.entrySet()Gets the entry set.int[]gets the object for the key.booleanisEmpty()Tests emptiness (size == 0).keySet()Gets the key set.protected voidloadKeys()Loads the keys from the .key file.voidPuts a int[] in the keyStore.int[]Remove by key.protected voidreset()Resets the file and creates a new key map.protected voidsaveKeys()Saves key file to disk.intsize()Gets the size of the key hash.
-
Field Details
-
logCacheName
The name to prefix log messages with. -
blockDiskCache
we need this so we can communicate free blocks to the data store when keys fall off the LRU
-
-
Constructor Details
-
BlockDiskKeyStore
public BlockDiskKeyStore(BlockDiskCacheAttributes cacheAttributes, BlockDiskCache<K, ?> blockDiskCache) Set the configuration options.- Parameters:
cacheAttributes-blockDiskCache- used for freeing
-
-
Method Details
-
clearMemoryMap
This is mainly used for testing. It leave the disk in tact, and just clears memory. -
entrySet
Gets the entry set.- Returns:
- entry set.
-
get
gets the object for the key.- Parameters:
key-- Returns:
- Object
-
isEmpty
Tests emptiness (size == 0).- Returns:
- Whether or not this is empty.
- Since:
- 3.1
-
keySet
Gets the key set.- Returns:
- key set.
-
loadKeys
Loads the keys from the .key file. The keys are stored individually on disk. They are added one by one to an LRUMap. -
put
Puts a int[] in the keyStore.- Parameters:
key-value-
-
remove
Remove by key.- Parameters:
key-- Returns:
- BlockDiskElementDescriptor if it was present, else null
-
reset
Resets the file and creates a new key map. -
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. -
size
Gets the size of the key hash.- Returns:
- the number of keys.
-