Class CacheMap
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClears the caches for this cache objectvoidClears the memory cachevoidClears the storage cachevoiddelete(java.lang.Object key) Deletes a cached entryjava.lang.Objectget(java.lang.Object key) Returns the object matching the given keyA prefix prepended to storage entries to differentiate themintIndicates the size of the memory cache after which the cache won't grow further Size is indicated by number of elements stored and not by KB or similar benchmark!Returns the keys for all the objects currently in cache, this is useful to traverse all the objects and refresh them without actually deleting the cache and fetching them from scratch.intIndicates the size of the storage cache after which the cache won't grow further Size is indicated by number of elements stored and not by KB or similar benchmark!booleanWhen set to true indicates that all entries should be persisted to storage for a constantly persisting cachevoidput(java.lang.Object key, java.lang.Object value) Puts the given key/value pair in the cachevoidsetAlwaysStore(boolean alwaysStore) When set to true indicates that all entries should be persisted to storage for a constantly persisting cachevoidsetCachePrefix(String cachePrefix) A prefix prepended to storage entries to differentiate themvoidsetCacheSize(int cacheSize) Indicates the size of the memory cache after which the cache won't grow further Size is indicated by number of elements stored and not by KB or similar benchmark!voidsetStorageCacheSize(int storageCacheSize) Indicates the size of the storage cache after which the cache won't grow further Size is indicated by number of elements stored and not by KB or similar benchmark!Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
CacheMap
public CacheMap()Default constructor -
CacheMap
Creates a cache map with a prefix string
Parameters
prefix: string to prepend to the cache entries in storage
-
-
Method Details
-
getCacheSize
public int getCacheSize()Indicates the size of the memory cache after which the cache won't grow further Size is indicated by number of elements stored and not by KB or similar benchmark!
Returns
the cacheSize
-
setCacheSize
public void setCacheSize(int cacheSize) Indicates the size of the memory cache after which the cache won't grow further Size is indicated by number of elements stored and not by KB or similar benchmark!
Parameters
cacheSize: the cacheSize to set
-
put
public void put(java.lang.Object key, java.lang.Object value) Puts the given key/value pair in the cache
Parameters
-
key: the key -
value: the value
-
-
delete
public void delete(java.lang.Object key) Deletes a cached entry
Parameters
key: entry to remove from the cache
-
get
public java.lang.Object get(java.lang.Object key) Returns the object matching the given key
Parameters
key: key object
Returns
value from a previous put or null
-
clearAllCache
public void clearAllCache()Clears the caches for this cache object -
clearMemoryCache
public void clearMemoryCache()Clears the memory cache -
getKeysInCache
Returns the keys for all the objects currently in cache, this is useful to traverse all the objects and refresh them without actually deleting the cache and fetching them from scratch.
Important this vector is a copy of a current state, keys might not exist anymore or might change, others might be added in the interim.
Returns
- Returns:
- a vector containing a snapshot of the current elements within the cache.
-
clearStorageCache
public void clearStorageCache()Clears the storage cache -
getStorageCacheSize
public int getStorageCacheSize()Indicates the size of the storage cache after which the cache won't grow further Size is indicated by number of elements stored and not by KB or similar benchmark!
Returns
the storageCacheSize
-
setStorageCacheSize
public void setStorageCacheSize(int storageCacheSize) Indicates the size of the storage cache after which the cache won't grow further Size is indicated by number of elements stored and not by KB or similar benchmark!
Parameters
storageCacheSize: the storageCacheSize to set
-
getCachePrefix
A prefix prepended to storage entries to differentiate them
Returns
the cachePrefix
-
setCachePrefix
A prefix prepended to storage entries to differentiate them
Parameters
cachePrefix: the cachePrefix to set
-
isAlwaysStore
public boolean isAlwaysStore()When set to true indicates that all entries should be persisted to storage for a constantly persisting cache
Returns
the alwaysStore
-
setAlwaysStore
public void setAlwaysStore(boolean alwaysStore) When set to true indicates that all entries should be persisted to storage for a constantly persisting cache
Parameters
alwaysStore: the alwaysStore to set
-