
Classes | |
| class | Entry< V > |
| class | GrimReaper |
Public Member Functions | |
| synchronized NSArray< K > | allKeys () |
| ERXExpiringCache (long expiryTimeInSeconds, long cleanupPauseInSeconds) | |
| ERXExpiringCache (long expiryTimeInSeconds) | |
| ERXExpiringCache () | |
| synchronized boolean | isStale (K key) |
| synchronized boolean | isStaleWithVersion (K key, Object currentVersionKey) |
| synchronized V | objectForKey (K key) |
| synchronized V | objectForKeyWithVersion (K key, Object currentVersionKey) |
| synchronized void | removeAllObjects () |
| synchronized V | removeObjectForKey (K key) |
| synchronized void | removeStaleEntries () |
| synchronized void | setObjectForKey (V object, K key) |
| synchronized void | setObjectForKeyWithVersion (V object, K key, Object currentVersionKey) |
| synchronized void | setObjectForKeyWithVersion (V object, K key, Object currentVersionKey, long expirationTime) |
| void | startBackgroundExpiration () |
| synchronized void | stopBackgroundExpiration () |
| String | toString () |
Static Public Attributes | |
| static final long | NO_TIMEOUT = 0L |
| static final Object | NO_VERSION = new Object() |
Protected Member Functions | |
| synchronized Entry< V > | entryForKey (K key) |
| synchronized void | removeEntryForKey (Entry< V > entry, K key) |
| synchronized void | setEntryForKey (Entry< V > entry, K key) |
Static Protected Member Functions | |
| static synchronized ERXExpiringCache.GrimReaper | reaper () |
Private Member Functions | |
| long | expiryTime () |
Private Attributes | |
| NSMutableDictionary< K, ERXExpiringCache.Entry< V > > | _backingDictionary |
| long | _cleanupPause |
| long | _expiryTime |
| long | _lastCleanupTime |
Static Private Attributes | |
| static ERXExpiringCache.GrimReaper | _reaper |
Note that on a time-expiring cache, if you do not use the reaper with startBackgroundExpiration(), or manually call removeStaleEntries(), unexpired entries will remain in the cache for the lifetime of the cache.
| ERXExpiringCache | ( | ) |
Constructs an ERXExpiringCache with a 60 second expiration.
| ERXExpiringCache | ( | long | expiryTimeInSeconds | ) |
Constructs an ERXExpiringCache with a cleanup time that matches expiryTimeInSeconds.
| expiryTimeInSeconds | the lifetime in seconds of an object in the cache or NO_TIMEOUT |
| ERXExpiringCache | ( | long | expiryTimeInSeconds, | |
| long | cleanupPauseInSeconds | |||
| ) |
| expiryTimeInSeconds | the lifetime in seconds of an object in the cache or NO_TIMEOUT | |
| cleanupPauseInSeconds | the number of seconds to pause between cleanups |
| synchronized NSArray<K> allKeys | ( | ) |
Returns all keys.
| synchronized Entry<V> entryForKey | ( | K | key | ) | [protected] |
| long expiryTime | ( | ) | [private] |
| synchronized boolean isStale | ( | K | key | ) |
Returns whether or not the object for the given key is a stale cache entry.
| key | the key to lookup |
| synchronized 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.
| key | the key to lookup | |
| currentVersionKey | the current version of this key |
| synchronized V objectForKey | ( | K | key | ) |
Returns the value of the given key with an unspecified version.
| key | the key to lookup with |
| synchronized V objectForKeyWithVersion | ( | K | key, | |
| Object | currentVersionKey | |||
| ) |
Returns the value of the given key passing in the current version of the cache value. If the version key passed in does not match the version key in the cache, the cache will invalidate that key.
| key | the key to lookup with | |
| currentVersionKey | the current version of this key |
| static synchronized ERXExpiringCache.GrimReaper reaper | ( | ) | [static, protected] |
Returns the repear for all ERXExpringCaches.
| synchronized void removeAllObjects | ( | ) |
Removes all the objects in this cache.
| synchronized void removeEntryForKey | ( | Entry< V > | entry, | |
| K | key | |||
| ) | [protected] |
| synchronized V removeObjectForKey | ( | K | key | ) |
Removes the object for the given key.
| key | the key to remove |
| synchronized void removeStaleEntries | ( | ) |
Removes all stale entries.
| synchronized void setEntryForKey | ( | Entry< V > | entry, | |
| K | key | |||
| ) | [protected] |
| synchronized void setObjectForKey | ( | V | object, | |
| K | key | |||
| ) |
Sets the object for the specified key in this cache with no version specified.
| object | the value to set | |
| key | the lookup key |
| synchronized void setObjectForKeyWithVersion | ( | V | object, | |
| K | key, | |||
| Object | currentVersionKey | |||
| ) |
Sets the object for the specified key and current version key.
| object | the object to set | |
| key | the lookup key | |
| currentVersionKey | the version of the object right now |
| synchronized void setObjectForKeyWithVersion | ( | V | object, | |
| K | key, | |||
| Object | currentVersionKey, | |||
| long | expirationTime | |||
| ) |
Sets the object for the specified key and current version key.
| object | the object to set | |
| key | the lookup key | |
| currentVersionKey | the version of the object right now |
| void startBackgroundExpiration | ( | ) |
Adds this cache to the background thread that reaps time-expired entries from expiring caches. If this cache is not a time-expiration cache, this will throw an IllegalArgumentException.
| synchronized void stopBackgroundExpiration | ( | ) |
Stops the background reaper for this cache.
| String toString | ( | ) |
NSMutableDictionary<K, ERXExpiringCache.Entry<V> > _backingDictionary [private] |
long _cleanupPause [private] |
long _expiryTime [private] |
long _lastCleanupTime [private] |
ERXExpiringCache.GrimReaper _reaper [static, private] |
The reaper for ERXExpiringCaches.
final long NO_TIMEOUT = 0L [static] |
Designates that no timeout was specified.
final Object NO_VERSION = new Object() [static] |
Designates that no explicit version was specified.
1.5.8