public class InProcessCache<K,V> extends Object implements CacheWithLifetimes<K,V>
| Constructor and Description |
|---|
InProcessCache(long maxObjects,
long defaultLifespan)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
delete all key-value pairs from the cache
|
void |
delete(K key)
delete a key-value pair from the cache
|
void |
deleteAll(List<K> keys)
delete one or more key-value pairs from the cache
|
V |
get(K key)
look up a value in the cache
|
Map<K,V> |
getAll(List<K> keys)
look up one or more values in the cache.
|
CacheEntry<V> |
getCacheEntry(K key)
look up a CacheEntry in the cache.
|
InProcessCacheStats |
getStatistics()
get cache statistics
|
String |
printCacheEntry(K key)
Return string representing a cache entry corresponding to a key (or indicate if the
key is not in the cache).
|
void |
put(K key,
V value)
cache a key-value pair
|
void |
put(K key,
V value,
long lifetime)
cache a key-value pair
|
void |
putAll(Map<K,V> map)
cache one or more key-value pairs
|
void |
putAll(Map<K,V> map,
long lifetime)
cache one or more key-value pairs
|
long |
size()
Return number of objects in cache
|
String |
toString()
Return contents of entire cache in a string
|
public InProcessCache(long maxObjects,
long defaultLifespan)
maxObjects - maximum number of objects which can be stored before
replacement startsdefaultLifespan - Default life time in milliseconds for cached objectspublic void clear()
public void delete(K key)
public Map<K,V> getAll(List<K> keys)
public CacheEntry<V> getCacheEntry(K key)
getCacheEntry in interface Cache<K,V>key - key corresponding to valuepublic InProcessCacheStats getStatistics()
getStatistics in interface Cache<K,V>public String printCacheEntry(K key)
key - key corresponding to valuepublic void put(K key, V value, long lifetime)
put in interface CacheWithLifetimes<K,V>key - key associated with valuevalue - value associated with keylifetime - lifetime in milliseconds associated with datapublic void putAll(Map<K,V> map, long lifetime)
putAll in interface CacheWithLifetimes<K,V>map - map containing key-value pairs to cachelifetime - lifetime in milliseconds associated with each key-value pairpublic long size()
Copyright © 2015. All rights reserved.