org.jboss.jca.adapters.jdbc.util

## Interface Cache<K,V>

- Type Parameters:
    `K` - The key
    `V` - The value
  All Known Implementing Classes:
    LRUCache

      public interface Cache<K,V>

  Interface that specifies a policy for caches.

  Implementation classes can implement a LRU policy, a random one, a MRU one, or any other suitable policy.

  Author:
    Simone Bordet

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `flush()` Flushes the cached objects from the cache.
    `V` | `get(K key)` Returns the object paired with the specified key if it's present in the cache, otherwise must return null.
    `void` | `insert(K key, V object)` Inserts the specified object into the cache following the implemented policy.
    `V` | `peek(K key)` Returns the object paired with the specified key if it's present in the cache, otherwise must return null.
    `void` | `remove(K key)` Remove the cached object paired with the specified key.
    `void` | `setListener(CacheListener<V> listener)` Set the cache listener
    `int` | `size()` The cache size

- - ### Method Detail

    - #### get

          V get(K key)

      Returns the object paired with the specified key if it's present in the cache, otherwise must return null.
      Implementations of this method must have complexity of order O(1). Differently from `peek(K)` this method not only return whether the object is present in the cache or not, but also applies the implemented policy that will "refresh" the cached object in the cache, because this cached object was really requested.
      Parameters:
        `key` - the key paired with the object
      Returns:
        the object
      See Also:
        `peek(K)`

    - #### peek

          V peek(K key)

      Returns the object paired with the specified key if it's present in the cache, otherwise must return null.
      Implementations of this method must have complexity of order O(1). This method should not apply the implemented caching policy to the object paired with the given key, so that a client can query if an object is cached without "refresh" its cache status. Real requests for the object must be done using `get(K)`.
      Parameters:
        `key` - the key paired with the object
      Returns:
        the object
      See Also:
        `get(K)`

    - #### insert

          void insert(K key,
                      V object)

      Inserts the specified object into the cache following the implemented policy.
      Implementations of this method must have complexity of order O(1).
      Parameters:
        `key` - the key paired with the object
        `object` - the object to cache
      See Also:
        `remove(K)`

    - #### remove

          void remove(K key)

      Remove the cached object paired with the specified key.
      Implementations of this method must have complexity of order O(1).
      Parameters:
        `key` - the key paired with the object
      See Also:
        `insert(K, V)`

    - #### flush

          void flush()

      Flushes the cached objects from the cache.

    - #### size

          int size()

      The cache size
      Returns:
        the size of the cache

    - #### setListener

          void setListener(CacheListener<V> listener)

      Set the cache listener
      Parameters:
        `listener` - The listener

Copyright © 2014 IronJacamar (http://www.ironjacamar.org)