Interface Cache

All Known Implementing Classes:
CacheLRU, GenericCache

public interface Cache
An interface defining the basic functions of a cache.
Since:
1.0
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addElement(Object key, Object value)
    Adds an element to the cache.
    int
    Returns the maximum number of elements that can be cached at one time.
    Gets an element from the cache.
    int
    Returns the number of elements in the cache, not to be confused with the capacity() which returns the number of elements that can be held in the cache at one time.
  • Method Details

    • addElement

      void addElement(Object key, Object value)
      Adds an element to the cache.
      Parameters:
      key - Key
      value - Value
    • getElement

      Object getElement(Object key)
      Gets an element from the cache.
      Parameters:
      key - Key
      Returns:
      Element value
    • size

      int size()
      Returns the number of elements in the cache, not to be confused with the capacity() which returns the number of elements that can be held in the cache at one time.

      Returns:
      The current size of the cache (i.e., the number of elements currently cached).
    • capacity

      int capacity()
      Returns the maximum number of elements that can be cached at one time.

      Returns:
      The maximum number of elements that can be cached at one time.