Class ObjectCaches

Object
ObjectCaches

public final class ObjectCaches extends Object
This is facade around several constructs used by GeoTools for internal caching.

This class provides the following services:

  • Access to an implementation of "weak", "all" and "none" implementations of ObjectCache.
  • The ability to turn a "code" into a good "key" for use with an ObjectCache.
  • A Pair data object (think of C STRUCT) for use as a key when storing a value against two objects.
Since:
2.5
Author:
Jody Garnett, Cory Horner
  • Method Details

    • chain

      public static <K, V> ObjectCache<K,V> chain(ObjectCache<K,V> level1, ObjectCache<K,V> level2)
      Create a two level cache, operates as a level1 cache that is willing to obtain values from a (usually shared) level2 cache.

      This functionality is used to tie two ObjectCache implementations together (allowing them to collaborate while focusing on different use cases). The real world example of chaining is in AbstractFindableAuthorityFactory in which:

      • create uses: chain( cache, findCache )
      • find uses: chain( findCache, cache )
      In this manner the find operation does not upset normal cache. It will not create any objects already present in the cache.
      Returns:
      ObjectCache
    • create

      public static <K, V> ObjectCache<K,V> create(Hints hints) throws FactoryRegistryException
      Utility method used to produce cache based on provide Hint
      Throws:
      FactoryRegistryException
    • create

      public static <K, V> ObjectCache<K,V> create(String policy, int size)
      Utility method used to produce an ObjectCache.
      Parameters:
      policy - One of "weak", "all", "none", "soft"
      size - Used to indicate requested size, exact use depends on policy
      Returns:
      A new ObjectCache
      See Also:
      • Hints.BUFFER_POLICY
    • toKey

      public static String toKey(Citation citation, String code)
      Produce a good key based on the privided citaiton and code. You can think of the citation as being "here" and the code being the "what".
      Parameters:
      code - Code
      Returns:
      A good key for use with ObjectCache
    • toKey

      public static Object toKey(Citation citation, String code1, String code2)
      Produce a good key based on a pair of codes.
      Returns:
      A object to use as a key