Interface ObjectCacheManager

All Known Implementing Classes:
ObjectCache

public interface ObjectCacheManager
This interface should be implemented by classes that contain a publicly available ObjectCache, it provides methods that allow applications to control the cache without understanding what is inside the cache.

All of the methods in this interface are optional and if not supported then implementing classes should throw UnsupportedOperationException.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Return the current capacity of the cache, it should basically be (max size - current size).
    void
    Let the object cache be flushed.
    boolean
    Return whether the cache is empty or not.
    void
    Merge the current cache with another.
    void
    putAll(Map map)
    Add all the entries in the Map to cache.
    void
    resize(int size)
    Resize the cache to a particular size, if the size is actually bigger than the current size then this operation should not touch the cached objects, if the size is less then the cache should be reduced in size using the current policy until the size is reached.
    void
    setMaxSize(int size)
    Set the maximum size of the cache.
    void
    setPolicy(int policy)
    Set the policy for managing the cache, should be one of: ObjectCache.OLDEST, ObjectCache.YOUNGEST, ObjectCache.RANDOM.
    void
    toMap(Map map)
    Get all the entries in the cache as a Map of key to value.
  • Method Details

    • flush

      void flush()
      Let the object cache be flushed.
    • setMaxSize

      void setMaxSize(int size)
      Set the maximum size of the cache.
      Parameters:
      size - The maximum size.
    • resize

      void resize(int size)
      Resize the cache to a particular size, if the size is actually bigger than the current size then this operation should not touch the cached objects, if the size is less then the cache should be reduced in size using the current policy until the size is reached. Either way the maximum size should be set to this value.
      Parameters:
      size - The new size.
    • capacity

      int capacity()
      Return the current capacity of the cache, it should basically be (max size - current size).
      Returns:
      The current number of items that can be added until the cache reaches it's maximum size.
    • isEmpty

      boolean isEmpty()
      Return whether the cache is empty or not.
      Returns:
      true if the cache is empty, false if it has entries.
    • toMap

      void toMap(Map map)
      Get all the entries in the cache as a Map of key to value.
      Parameters:
      map - The Map that should be populated with the key/values in the cache.
    • merge

      void merge(ObjectCache cache)
      Merge the current cache with another.
      Parameters:
      cache - The cache to merge.
    • putAll

      void putAll(Map map)
      Add all the entries in the Map to cache.
      Parameters:
      map - The Map to get key/values from.
    • setPolicy

      void setPolicy(int policy)
      Set the policy for managing the cache, should be one of: ObjectCache.OLDEST, ObjectCache.YOUNGEST, ObjectCache.RANDOM.
      Parameters:
      policy - The policy.