K
- the key of the mapT
- the valuepublic class CacheMap<K,T> extends Object
Modifier and Type | Class and Description |
---|---|
protected class |
CacheMap.CacheObject
inner class for managing the cache entries
|
Modifier and Type | Field and Description |
---|---|
protected Map<K,CacheMap.CacheObject> |
cacheMap |
protected ReadWriteLock |
readWriteLock |
protected long |
timeToLive |
Constructor and Description |
---|
CacheMap(long timeToLive,
long cleanupInterval)
Constructs a new CacheMap
|
Modifier and Type | Method and Description |
---|---|
void |
cleanup()
Cleanup the map checking the time to live for each entry
|
void |
cleanup(boolean force)
Cleanup the map checking the time to live for each entry or force cleaning
|
T |
get(K key)
Get the specified object from the map (or null if no object is found)
|
void |
put(K key,
T value)
Put a new object to the map
|
void |
remove(K key)
Removes the specified object from the map
|
int |
size()
Get the actual size of the map
|
protected long timeToLive
protected Map<K,CacheMap.CacheObject> cacheMap
protected ReadWriteLock readWriteLock
public CacheMap(long timeToLive, long cleanupInterval)
timeToLive
- time to live in the map (in seconds)cleanupInterval
- cache cleaning interval (in seconds)public void put(K key, T value)
key
- the key of the entryvalue
- the value of the entrypublic T get(K key)
key
- the key of the entry to getpublic void remove(K key)
key
- the key of the entrypublic int size()
public void cleanup()
public void cleanup(boolean force)
force
- force cleanupCopyright © 2012–2017 tinyMediaManager. All rights reserved.