Class ExpiringCache<T extends Cacheable>
java.lang.Object
org.deltava.util.cache.Cache<T>
org.deltava.util.cache.ExpiringCache<T>
- Type Parameters:
- T- the Cacheable object type
- Direct Known Subclasses:
- ExpiringGeoCache
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected classExpiringCache.ExpiringLocalCacheEntry<U extends T>protected classExpiringCache.ExpiringNullCacheEntry<U extends T>A null cache entry for expiring caches.
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidAdds an entry to the cache.protected voidaddNullEntry(Object key) Adds a null entry to the cache.protected voidPurges expired entries from the cache.booleanReturns if the cache contains a particular cache key and the key has not expired.Returns an unexpired entry from the cache.Returns an entry from the cache.booleanQueries the cache to determine if an object has expiredvoidsetExpiration(int expiry) Sets the cache's expiration interval.
- 
Field Details- 
_lastCreationTimeprotected long _lastCreationTime
- 
_expiryprotected int _expiry
 
- 
- 
Constructor Details- 
ExpiringCachepublic ExpiringCache(int maxSize, int expiryTime) Creates a new Cache.- Parameters:
- maxSize- the maximum number of entries
- expiryTime- the expiration time in seconds
- Throws:
- IllegalArgumentException- if maxSize or expiryTime are zero or negative
- See Also:
 
 
- 
- 
Method Details- 
setExpirationpublic void setExpiration(int expiry) Sets the cache's expiration interval.- Parameters:
- expiry- the expiration interval in seconds
 
- 
get
- 
contains
- 
get
- 
isExpiredQueries the cache to determine if an object has expired- Parameters:
- key- the cache key
- Returns:
- TRUE if the object is present and expired, otherwise FALSE
 
- 
addEntry
- 
addNullEntryAdds a null entry to the cache.- Specified by:
- addNullEntryin class- Cache<T extends Cacheable>
- Parameters:
- key- the entry key
 
- 
checkOverflowprotected void checkOverflow()Purges expired entries from the cache.- Overrides:
- checkOverflowin class- Cache<T extends Cacheable>
 
 
-