Package: org.apache.groovy.json.internal

## [Java] Class SimpleCache<K, V>

- org.apache.groovy.json.internal.SimpleCache

- All Implemented Interfaces and Traits:
    Cache

      public class SimpleCache<K, V>
      extends Object
      implements Cache

  Thin adapter that exposes CommonCache through the internal Cache API.

  Type Parameters:
    `K` - the key type
    `V` - the value type

- - ### Constructor Summary

    Constructors
    Constructor and description
    `SimpleCache(int limit, CacheType type)` Creates a cache with the supplied size limit and eviction policy.
    `SimpleCache(int limit)` Creates an LRU cache with the supplied size limit.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public V` | `get(K key)` * Retrieves a value and updates cache state as needed. * * Parameters: `key` - the cache key * Returns: the cached value, or `null` if absent
    `` | `public V` | `getSilent(K key)` * Retrieves a value using implementation-specific silent access semantics. * * Parameters: `key` - the cache key * Returns: the cached value, or `null` if absent
    `` | `public void` | `put(K key, V value)` * Stores a value under the supplied key. * * Parameters: `key` - the cache key * `value` - the cached value
    `` | `public void` | `remove(K key)` * Removes the value stored for the supplied key. * * Parameters: `key` - the cache key
    `` | `public int` | `size()` * Returns the current number of cached entries. * * Returns: the cache size
    `` | `public String` | `toString()` Returns the underlying cache state as a string.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### public SimpleCache(int limit, CacheType type)

      Creates a cache with the supplied size limit and eviction policy.

      Parameters:
        `limit` - the maximum number of entries
        `type` - the eviction strategy

    - #### public SimpleCache(int limit)

      Creates an LRU cache with the supplied size limit.

      Parameters:
        `limit` - the maximum number of entries

  - ### Method Detail

    - #### public V get(K key)

      * Retrieves a value and updates cache state as needed. * *

      Parameters:
        `key` - the cache key *
      Returns:
        the cached value, or `null` if absent

    - #### public V getSilent(K key)

      * Retrieves a value using implementation-specific silent access semantics. * *

      Parameters:
        `key` - the cache key *
      Returns:
        the cached value, or `null` if absent

    - #### public void put(K key, V value)

      * Stores a value under the supplied key. * *

      Parameters:
        `key` - the cache key *
        `value` - the cached value

    - #### public void remove(K key)

      * Removes the value stored for the supplied key. * *

      Parameters:
        `key` - the cache key

    - #### public int size()

      * Returns the current number of cached entries. * *

      Returns:
        the cache size

    - #### public String toString()

      Returns the underlying cache state as a string.

      Returns:
        the cache state string