Class ExpiringGeoCache<T extends Cacheable>
java.lang.Object
org.deltava.util.cache.Cache<T>
org.deltava.util.cache.ExpiringCache<T>
org.deltava.util.cache.ExpiringGeoCache<T>
- Type Parameters:
T- the Cacheable object type
- All Implemented Interfaces:
GeoCache<T>
A cache to store geographic lookups. Lat/long coordinates are automatically reduced to a set number of decimal places.
- Since:
- 7.3
- Version:
- 7.4
- Author:
- Luke
-
Nested Class Summary
Nested classes/interfaces inherited from class ExpiringCache
ExpiringCache.ExpiringLocalCacheEntry<U>, ExpiringCache.ExpiringNullCacheEntry<U>Modifier and TypeClassDescriptionprotected classExpiringCache.ExpiringLocalCacheEntry<U extends T>protected classExpiringCache.ExpiringNullCacheEntry<U extends T>A null cache entry for expiring caches. -
Field Summary
Fields inherited from class ExpiringCache
_expiry, _lastCreationTime -
Constructor Summary
ConstructorsConstructorDescriptionExpiringGeoCache(int maxSize, int expiryTime, double roundAmt) Creates a new Cache. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(GeoLocation loc, T data) Adds a geographically located object to the cache.voidaddNull(GeoLocation loc) Adds a null entry to the cache.booleancontains(GeoLocation loc) Returns whether the cache contains an entry for a particular location.get(GeoLocation loc) Retrieves an object from the cache.doubleReturns the precision of the lat/long key rounding.voidremove(GeoLocation loc) Removes a location entry from the cache.Methods inherited from class ExpiringCache
addEntry, addNullEntry, checkOverflow, contains, get, get, isExpired, setExpirationModifier 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.Methods inherited from class Cache
add, addAll, addNull, clear, getAll, getErrors, getHits, getMaxSize, getRequests, hit, isRemote, remove, request, setMaxSize, sizeModifier and TypeMethodDescriptionfinal voidAdds an entry to the cache.voidaddAll(Collection<? extends T> entries) Adds a number of entries to the cache.final voidAdds a null entry to the cache.voidclear()Clears the cache.getAll(Collection<?> keys) Returns multiple objects from the cache.longReturns the total number of cache errors.final longgetHits()Returns the total number of cache hits.intReturns the maximum size of the cache.final longReturns the total number of cache requests.protected voidhit()Log a cache hit.booleanisRemote()Returns if the cache is a remote cache.voidInvalidate a cache entry.protected voidrequest()Log a cache request.final voidsetMaxSize(int size) Sets the maximum size of the cache.intsize()Returns the current size of the cache.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface GeoCache
createGeoKeyModifier and TypeMethodDescriptiondefault StringcreateGeoKey(GeoLocation loc) Creates a lat/long key by rounding to the specific number of decimal places.
-
Constructor Details
-
ExpiringGeoCache
public ExpiringGeoCache(int maxSize, int expiryTime, double roundAmt) Creates a new Cache.- Parameters:
maxSize- the maximum number of entriesexpiryTime- the expiration time in secondsroundAmt- the number of decimal places to round to- See Also:
-
-
Method Details
-
getRoundingAmount
public double getRoundingAmount()Description copied from interface:GeoCacheReturns the precision of the lat/long key rounding.- Specified by:
getRoundingAmountin interfaceGeoCache<T extends Cacheable>- Returns:
- the rounding amount
-
add
-
addNull
Adds a null entry to the cache. -
contains
Returns whether the cache contains an entry for a particular location. -
get
-
remove
Removes a location entry from the cache.
-