Package io.rong.imkit.widget.cache

## Class RongCache

- All Implemented Interfaces:

      public class RongCache<K, V>

  Modify by DragonJ on 14/11/28. Add queue for change the way of recycle.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `RongCache(int maxSize)` |

  - ### Enum Constant Summary

    Enum Constants
    Enum Constant | Description
    --- | ---

  - ### Method Summary

    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `resize(int maxSize)` | Sets the size of the cache.
    `final V` | `get(K key)` | Returns the value for `key` if it exists in the cache or can be created by `#create`.
    `final V` | `put(K key, V value)` | Caches `value` for `key`.
    `final V` | `remove(K key)` | Removes the entry for `key` if it exists.
    `void` | `clear()` |
    `final void` | `evictAll()` | Clear the cache, calling entryRemoved on each removed entry.
    `final synchronized int` | `size()` | For caches that do not override sizeOf, this returns the number of entries in the cache.
    `final synchronized int` | `maxSize()` | For caches that do not override sizeOf, this returns the maximum number of entries in the cache.
    `final synchronized int` | `hitCount()` | Returns the number of times get returned a value that was already present in the cache.
    `final synchronized int` | `missCount()` | Returns the number of times get returned null or required a new value to be created.
    `final synchronized int` | `createCount()` | Returns the number of times create returned a value.
    `final synchronized int` | `putCount()` | Returns the number of times put was called.
    `final synchronized int` | `evictionCount()` | Returns the number of values that have been evicted.
    `final synchronized Map<K, V>` | `snapshot()` | Returns a copy of the current contents of the cache, ordered from least recently accessed to most recently accessed.
    `final synchronized String` | `toString()` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### RongCache

          RongCache(int maxSize)

      Parameters:
        `maxSize` - for caches that do not override sizeOf, this is the maximum number of entries in the cache.

  - ### Method Detail

    - #### resize

           void resize(int maxSize)

      Sets the size of the cache.

      Parameters:
        `maxSize` - The new maximum size.

    - #### get

           final V get(K key)

      Returns the value for `key` if it exists in the cache or can be created by `#create`. If a value was returned, it is moved to the head of the queue. This returns null if a value is not cached and cannot be created.

    - #### put

           final V put(K key, V value)

      Caches `value` for `key`. The value is moved to the head of the queue.

      Returns:

        the previous value mapped by `key`.

    - #### remove

           final V remove(K key)

      Removes the entry for `key` if it exists.

      Returns:

        the previous value mapped by `key`.

    - #### clear

           void clear()

    - #### evictAll

           final void evictAll()

      Clear the cache, calling entryRemoved on each removed entry.

    - #### size

           final synchronized int size()

      For caches that do not override sizeOf, this returns the number of entries in the cache. For all other caches, this returns the sum of the sizes of the entries in this cache.

    - #### maxSize

           final synchronized int maxSize()

      For caches that do not override sizeOf, this returns the maximum number of entries in the cache. For all other caches, this returns the maximum sum of the sizes of the entries in this cache.

    - #### hitCount

           final synchronized int hitCount()

      Returns the number of times get returned a value that was already present in the cache.

    - #### missCount

           final synchronized int missCount()

      Returns the number of times get returned null or required a new value to be created.

    - #### createCount

           final synchronized int createCount()

      Returns the number of times create returned a value.

    - #### putCount

           final synchronized int putCount()

      Returns the number of times put was called.

    - #### evictionCount

           final synchronized int evictionCount()

      Returns the number of values that have been evicted.

    - #### snapshot

           final synchronized Map<K, V> snapshot()

      Returns a copy of the current contents of the cache, ordered from least recently accessed to most recently accessed.

    - #### toString

           final synchronized String toString()