Interface SmartCache<K,V>

All Known Implementing Classes:
HardSmartCache, SmartCacheImpl, SoftSmartCache

public interface SmartCache<K,V>
Defines a cache API. Implementations exist for hard and soft references.

To iterate over the contents of a cache, you must pass a execute(SmartCacheTask) instance. The code using the iterator can be assured that it will be thread safe.

Implementations are responsible of enforcing thread safety.

Since:
Nov 21, 2005
Author:
av
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Defines a task to be run over the entries of the cache.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears the contents of this cache.
    void
    Executes a task over the contents of the cache and guarantees exclusive write access while processing.
    get(K key)
    Looks up and returns a cache value according to a given key.
    put(K key, V value)
    Places a key/value pair into the cache.
    remove(K key)
    Removes a key from the cache.
    int
    Returns the number of elements in cache.
  • Method Details

    • put

      V put(K key, V value)
      Places a key/value pair into the cache.
      Parameters:
      key - Key
      value - Value
      Returns:
      the previous value of key or null
    • get

      V get(K key)
      Looks up and returns a cache value according to a given key. If the cache does not correspond an entry corresponding to the key, null is returned.
    • remove

      V remove(K key)
      Removes a key from the cache.
      Parameters:
      key - Key
      Returns:
      Previous value associated with the key
    • clear

      void clear()
      Clears the contents of this cache.
    • size

      int size()
      Returns the number of elements in cache.
    • execute

      void execute(SmartCache.SmartCacheTask<K,V> task)
      Executes a task over the contents of the cache and guarantees exclusive write access while processing.
      Parameters:
      task - The task to execute.