Cache

interface Cache<Key : Any, Value : Any>

Functions

Link copied to clipboard
abstract fun getAllPresent(): Map<Key, Value>
abstract fun getAllPresent(keys: List<*>): Map<Key, Value>
Link copied to clipboard
abstract fun getIfPresent(key: Key): Value?
Link copied to clipboard
abstract fun getOrPut(key: Key, valueProducer: () -> Value): Value
Link copied to clipboard
abstract fun invalidate(key: Key)

Discards any cached value associated with key.

Link copied to clipboard
abstract fun invalidateAll()

Discards all entries in the cache.

abstract fun invalidateAll(keys: List<Key>)

Discards any cached value associated for keys.

Link copied to clipboard
abstract fun put(key: Key, value: Value)

Associates value with key. If the cache previously contained a value associated with key, the old value is replaced by value. Prefer getOrPut when using the conventional "If cached, then return. Otherwise create, cache, and then return" pattern.

Link copied to clipboard
abstract fun putAll(map: Map<Key, Value>)

Copies all of the mappings from the specified map to the cache. The effect of this call is equivalent to that of calling put on this map once for each mapping from Key to Value in the specified map. The behavior of this operation is undefined if the specified map is modified while the operation is in progress.

Link copied to clipboard
abstract fun size(): Long