LruCache

open class LruCache<T, Y>

A general purpose size limited cache that evicts items using an LRU algorithm. By default every item is assumed to have a size of one. Subclasses can override getSize} to change the size on a per item basis.

Parameters

<T>

The type of the keys.

<Y>

The type of the values.

Constructors

Link copied to clipboard
open fun LruCache(size: Long)
Constructor for LruCache.

Functions

Link copied to clipboard
open fun clearMemory()
Clears all items in the cache.
Link copied to clipboard
open fun contains(key: T): Boolean
Returns true if there is a value for the given key in the cache.
Link copied to clipboard
open fun get(key: T): Y
Returns the item in the cache for the given key or null if no such item exists.
Link copied to clipboard
open fun put(key: T, item: Y): Y
Adds the given item to the cache with the given key and returns any previous entry for the given key that may have already been in the cache.
Link copied to clipboard
open fun remove(key: T): Y
Removes the item at the given key and returns the removed item if present, and null otherwise.
Link copied to clipboard
open fun setSizeMultiplier(multiplier: Float)
Sets a size multiplier that will be applied to the size provided in the constructor to put the new size of the cache.

Properties

Link copied to clipboard
open val currentSize: Long
Link copied to clipboard
open val maxSize: Long

Inheritors

Link copied to clipboard