Cache

interface Cache<K, V>(source)

A contract that defines a semi-persistent mapping of keys and values. Cache entries are manually added using put(K, V), and are stored in the cache until either evicted or manually removed. After storing a value, it can be accessed using get(K).

Parameters

<K>

The type of the key.

<V>

The type of the value.

Functions

Link copied to clipboard
abstract fun contains(key: K): Boolean
Returns True if the cache contains a entry with the key, or False if there is none.
Link copied to clipboard
abstract fun get(key: K): Optional<V>
Returns the value associated with key in this cache, or empty if there is no cached value for key.
Link copied to clipboard
abstract fun isEmpty(): Boolean
Returns True if the cache is empty, or False if there's at least a entry stored in cache.
Link copied to clipboard
abstract fun put(key: K, value: V)
Associates value with key in this cache.
Link copied to clipboard
abstract fun remove(key: K)
Discards any cached value for this key.
Link copied to clipboard
abstract fun removeAll()
Discards all entries in the cache.
Link copied to clipboard
abstract fun size(): Long
Returns the number of entries in this cache.
Link copied to clipboard
abstract fun stats(): CacheStats
Returns a current snapshot of this cache's cumulative statistics, or a set of default values if the cache is not recording statistics.