public class ERXExpiringCache<K,V> extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ERXExpiringCache.Entry<V> |
protected static class |
ERXExpiringCache.GrimReaper
The reaper runnable for ERXExpiringCache.
|
Modifier and Type | Field and Description |
---|---|
static long |
NO_TIMEOUT
Designates that no timeout was specified.
|
static Object |
NO_VERSION
Designates that no explicit version was specified.
|
Constructor and Description |
---|
ERXExpiringCache()
Constructs an ERXExpiringCache with a 60 second expiration.
|
ERXExpiringCache(long expiryTimeInSeconds)
Constructs an ERXExpiringCache with a cleanup time that matches
expiryTimeInSeconds.
|
ERXExpiringCache(long expiryTimeInSeconds,
long cleanupPauseInSeconds) |
Modifier and Type | Method and Description |
---|---|
NSArray<K> |
allKeys()
Returns all keys.
|
protected ERXExpiringCache.Entry<V> |
entryForKey(K key) |
boolean |
isStale(K key)
Returns whether or not the object for the given key is a stale cache
entry.
|
boolean |
isStaleWithVersion(K key,
Object currentVersionKey)
Returns whether or not the object for the given key is a stale cache
entry given the context of the current version of the key.
|
V |
objectForKey(K key)
Returns the value of the given key with an unspecified version.
|
V |
objectForKeyWithVersion(K key,
Object currentVersionKey)
Returns the value of the given key passing in the current version of the
cache value.
|
protected static ERXExpiringCache.GrimReaper |
reaper()
Returns the repear for all ERXExpringCaches.
|
void |
removeAllObjects()
Removes all the objects in this cache.
|
protected void |
removeEntryForKey(ERXExpiringCache.Entry<V> entry,
K key) |
V |
removeObjectForKey(K key)
Removes the object for the given key.
|
void |
removeStaleEntries()
Removes all stale entries.
|
protected void |
setEntryForKey(ERXExpiringCache.Entry<V> entry,
K key) |
void |
setObjectForKey(V object,
K key)
Sets the object for the specified key in this cache with no version
specified.
|
void |
setObjectForKeyWithVersion(V object,
K key,
Object currentVersionKey)
Sets the object for the specified key and current version key.
|
void |
setObjectForKeyWithVersion(V object,
K key,
Object currentVersionKey,
long expirationTime)
Sets the object for the specified key and current version key.
|
void |
startBackgroundExpiration()
Adds this cache to the background thread that reaps time-expired entries
from expiring caches.
|
void |
stopBackgroundExpiration()
Stops the background reaper for this cache.
|
String |
toString() |
public static final long NO_TIMEOUT
public static final Object NO_VERSION
public ERXExpiringCache()
public ERXExpiringCache(long expiryTimeInSeconds)
expiryTimeInSeconds
- the lifetime in seconds of an object in the cache or
NO_TIMEOUTpublic ERXExpiringCache(long expiryTimeInSeconds, long cleanupPauseInSeconds)
expiryTimeInSeconds
- the lifetime in seconds of an object in the cache or
NO_TIMEOUTcleanupPauseInSeconds
- the number of seconds to pause between cleanupspublic void removeAllObjects()
public void setObjectForKey(V object, K key)
object
- the value to setkey
- the lookup keypublic void setObjectForKeyWithVersion(V object, K key, Object currentVersionKey, long expirationTime)
object
- the object to setkey
- the lookup keycurrentVersionKey
- the version of the object right nowpublic void setObjectForKeyWithVersion(V object, K key, Object currentVersionKey)
object
- the object to setkey
- the lookup keycurrentVersionKey
- the version of the object right nowpublic V objectForKey(K key)
key
- the key to lookup withpublic V objectForKeyWithVersion(K key, Object currentVersionKey)
key
- the key to lookup withcurrentVersionKey
- the current version of this keypublic boolean isStale(K key)
key
- the key to lookuppublic boolean isStaleWithVersion(K key, Object currentVersionKey)
key
- the key to lookupcurrentVersionKey
- the current version of this keypublic V removeObjectForKey(K key)
key
- the key to removepublic void removeStaleEntries()
protected void removeEntryForKey(ERXExpiringCache.Entry<V> entry, K key)
protected void setEntryForKey(ERXExpiringCache.Entry<V> entry, K key)
protected ERXExpiringCache.Entry<V> entryForKey(K key)
public void startBackgroundExpiration()
public void stopBackgroundExpiration()
protected static ERXExpiringCache.GrimReaper reaper()
Copyright © 2002 – 2024 Project Wonder.