Class JedisGeoCache<T extends Cacheable>
java.lang.Object
org.deltava.util.cache.Cache<T>
org.deltava.util.cache.JedisCache<T>
org.deltava.util.cache.JedisGeoCache<T>
- Type Parameters:
T- the Cacheable object type
- All Implemented Interfaces:
GeoCache<T>
A cache to store geographic lookups in Redis. Lat/long coordinates are automatically reduced to a set number of decimal places.
- Since:
- 7.3
- Version:
- 11.3
- Author:
- Luke
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionJedisGeoCache(String bucket, int expiry, double roundAmt) Creates the 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 JedisCache
addAll, addEntry, addNullEntry, clear, contains, createKey, get, getAll, getErrors, getExpiryTime, getMaxSize, isRemote, remove, sizeModifier and TypeMethodDescriptionvoidaddAll(Collection<? extends T> entries) Adds a number of entries to the cache.protected voidAdds an entry to the cache.protected voidaddNullEntry(Object key) Adds a null entry to the cache.voidclear()Clears the cache.booleanReturns if the cache contains a particular cache key.protected StringCreates a Jedis bucket:key key.Retrieves an entry from the cache.getAll(Collection<?> keys) Returns multiple objects from the cache.longReturns the total number of cache errors.protected longgetExpiryTime(T entry) Returns the expiration time for a cache entry, based on the cache or the entry's expiration time.intThis method is repurposed to deliver the round-trip latency to the cache server.booleanisRemote()Returns if the cache is a remote cache.voidInvalidate a cache entry.intsize()Returns the current size of the cache.Methods inherited from class Cache
add, addNull, checkOverflow, getHits, getRequests, hit, request, setMaxSizeModifier and TypeMethodDescriptionfinal voidAdds an entry to the cache.final voidAdds a null entry to the cache.protected voidAutomatically resizes the cache in the case of an overflow.final longgetHits()Returns the total number of cache hits.final longReturns the total number of cache requests.protected voidhit()Log a cache hit.protected voidrequest()Log a cache request.final voidsetMaxSize(int size) Sets the maximum 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
-
JedisGeoCache
Creates the cache.- Parameters:
bucket- the Redis bucket nameexpiry- the expirty time in secondsroundAmt- the rounding factot to apply to latitude/longitude
-
-
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.
-