Class NullCache<T extends Cacheable>

java.lang.Object
org.deltava.util.cache.Cache<T>
org.deltava.util.cache.NullCache<T>
Type Parameters:
T - the Cacheable object type
All Implemented Interfaces:
GeoCache<T>

public class NullCache<T extends Cacheable> extends Cache<T> implements GeoCache<T>
A cache implementation that does no caching. This is used to ensure that CacheManager never returns null.
Since:
5.0
Version:
11.3
Author:
Luke
  • Constructor Details

    • NullCache

      NullCache()
      Creates a new null cache.
  • Method Details

    • getMaxSize

      public final int getMaxSize()
      Returns the maximum size of the cache.
      Overrides:
      getMaxSize in class Cache<T extends Cacheable>
      Returns:
      the maximum number of entries in the cache
    • addEntry

      protected void addEntry(T entry)
      Description copied from class: Cache
      Adds an entry to the cache. Subclasses need to implement this method to handle cache additions, the public method forces an overflow check.
      Specified by:
      addEntry in class Cache<T extends Cacheable>
      Parameters:
      entry - the entry to add
    • addNullEntry

      protected void addNullEntry(Object key)
      Description copied from class: Cache
      Adds a null entry to the cache. Subclasses need to implement this method to handle cache additions, the public method forces an overflow check.
      Specified by:
      addNullEntry in class Cache<T extends Cacheable>
      Parameters:
      key - the entry key
    • get

      public T get(Object key)
      Description copied from class: Cache
      Retrieves an entry from the cache.
      Specified by:
      get in class Cache<T extends Cacheable>
      Parameters:
      key - the cache key
      Returns:
      the cache entry, or null if the key is not present or the entry is invalid
    • 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)
      Description copied from interface: GeoCache
      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)
      Description copied from interface: GeoCache
      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)
      Description copied from interface: GeoCache
      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)
      Description copied from interface: GeoCache
      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
    • getAll

      public Map<Object,T> getAll(Collection<?> keys)
      Description copied from class: Cache
      Returns multiple objects from the cache.
      Overrides:
      getAll in class Cache<T extends Cacheable>
      Parameters:
      keys - the cache keys
      Returns:
      a Map of results keyed by cache key
    • remove

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