Class ExpiringGeoCache<T extends Cacheable>

Type Parameters:
T - the Cacheable object type
All Implemented Interfaces:
GeoCache<T>

public class ExpiringGeoCache<T extends Cacheable> extends ExpiringCache<T> implements 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
  • Constructor Details

    • ExpiringGeoCache

      public ExpiringGeoCache(int maxSize, int expiryTime, double roundAmt)
      Creates a new Cache.
      Parameters:
      maxSize - the maximum number of entries
      expiryTime - the expiration time in seconds
      roundAmt - the number of decimal places to round to
      See Also:
  • Method Details

    • getRoundingAmount

      public double getRoundingAmount()
      Description copied from interface: GeoCache
      Returns the precision of the lat/long key rounding.
      Specified by:
      getRoundingAmount in interface GeoCache<T extends Cacheable>
      Returns:
      the rounding amount
    • add

      public void add(GeoLocation loc, T data)
      Adds a geographically located object to the cache.
      Specified by:
      add in interface GeoCache<T extends Cacheable>
      Parameters:
      loc - the GeoLocation
      data - the data to cache
    • addNull

      public void addNull(GeoLocation loc)
      Adds a null entry to the cache.
      Specified by:
      addNull in interface GeoCache<T extends Cacheable>
      Parameters:
      loc - the GeoLocation
    • contains

      public boolean contains(GeoLocation loc)
      Returns whether the cache contains an entry for a particular location.
      Specified by:
      contains in interface GeoCache<T extends Cacheable>
      Parameters:
      loc - the GeoLocation
      Returns:
      TRUE if the cache contains an entry, otherwise FALSE
    • get

      public T get(GeoLocation loc)
      Retrieves an object from the cache.
      Specified by:
      get in interface GeoCache<T extends Cacheable>
      Parameters:
      loc - the GeoLocation
      Returns:
      the Object, or null if not found
    • remove

      public void remove(GeoLocation loc)
      Removes a location entry from the cache.
      Specified by:
      remove in interface GeoCache<T extends Cacheable>
      Parameters:
      loc - the GeoLocation