suparnatural-cache / com.suparnatural.core.cache / FifoCacheReplacementPolicy

FifoCacheReplacementPolicy

class FifoCacheReplacementPolicy : CacheReplacementPolicy

A cache replacement policy which evicts the oldest object from cache to make space when cache is full.

Constructors

<init>

FifoCacheReplacementPolicy(cacheSize: Int)

A cache replacement policy which evicts the oldest object from cache to make space when cache is full.

Properties

cacheSize

val cacheSize: Int

Size of the cache

Functions

clearRegistryUnsafe

fun clearRegistryUnsafe(): Unit

Clear any state and reset to initial. For example, clearRegistryUnsafe any linked list state for LRU or FIFO cache.

evictUnsafe

fun evictUnsafe(): CacheableContainer?

Prune the cache by 1 entry. Returns the removed object. Call this method when cache runs out of space.

registerObjectUnsafe

fun registerObjectUnsafe(obj: CacheableContainer): CacheableContainer?

Adds a cache entry for the object and returns the entry of a pruned object. Pruning occurs when the cache space is full.

unregisterObjectUnsafe

fun unregisterObjectUnsafe(obj: CacheableContainer): Unit

Remove obj from cache registry.