K
- key typeV
- value typepublic class ExpirableCache<K,V> extends Object implements Serializable
Modifier and Type | Class and Description |
---|---|
static class |
ExpirableCache.ExpirableCacheUnit
unit of time for expirable cache
|
Constructor and Description |
---|
ExpirableCache() |
ExpirableCache(ExpirableCache.ExpirableCacheUnit expirableCacheUnit,
int defaultTimeToLive) |
ExpirableCache(int defaultTimeToLiveInMinutes) |
Modifier and Type | Method and Description |
---|---|
void |
checkForEvictions(boolean onlyCheckIfNeeded)
check and remove elements that are stale
|
void |
clear()
delete the cache
|
static void |
clearAll()
clear out all caches everywhere (session, request, context, etc)
|
static boolean |
clearCache(String name)
if there is a database clearable cache with this name, clear it
|
V |
get(K key)
get a value or null if not there or expired
this will check for eviction, and evict if evictable
|
int |
getCacheEvictions()
number of items evicted from cache
|
int |
getCacheHits()
number of items successfully retrieved from cache
|
int |
getCacheInserts()
number of items inserted into the cache
|
long |
getDefaultTimeToLiveInMillis()
expose the length of cache
|
void |
notifyDatabaseOfChanges() |
void |
put(K key,
V value)
put a value into the cache, accept the default time to live for this cache
|
void |
put(K key,
V value,
int timeToLiveInMinutes)
put a value into the cache, accept the default time to live for this cache
|
void |
registerDatabaseClearableCache(String name)
register a cache for database clearable.
|
int |
size(boolean evictEvictables)
number of elements in map (and check for
|
static String |
staticToString()
string representation of cache
|
String |
toString()
string representation of cache
|
public ExpirableCache()
public ExpirableCache(int defaultTimeToLiveInMinutes)
defaultTimeToLiveInMinutes
- time in minutes is the default cache time to live for contentpublic ExpirableCache(ExpirableCache.ExpirableCacheUnit expirableCacheUnit, int defaultTimeToLive)
defaultTimeToLive
- time in whatever unit is the default cache time to live for contentexpirableCacheUnit
- is minutes or secondspublic static boolean clearCache(String name)
name
- public void registerDatabaseClearableCache(String name)
name
- public void clear()
public long getDefaultTimeToLiveInMillis()
public void notifyDatabaseOfChanges()
public void put(K key, V value)
key
- value
- public void put(K key, V value, int timeToLiveInMinutes)
key
- value
- timeToLiveInMinutes
- time to live for this item in minutes.
If -1 then use the defaultpublic static void clearAll()
public void checkForEvictions(boolean onlyCheckIfNeeded)
onlyCheckIfNeeded
- true if only check every so often (e.g. every two minutes)public V get(K key)
key
- public int size(boolean evictEvictables)
evictEvictables
- true if we should evict values that are stale
(even if recently checked)public int getCacheInserts()
public int getCacheEvictions()
public int getCacheHits()
public String toString()
toString
in class Object
Object.toString()
public static String staticToString()
Copyright © 2016 Internet2. All rights reserved.