MemoryCache

class MemoryCache(nextCache: NormalizedCache? = null, maxSizeBytes: Int = Int.MAX_VALUE, expireAfterMillis: Long = -1) : NormalizedCache

Memory (multiplatform) cache implementation based on recently used property (LRU).

maxSizeBytes - the maximum size in bytes the cache may occupy. expireAfterMillis - after what timeout each entry in the cache treated as expired. By default there is no timeout.

Expired entries removed from the cache only on cache miss (loadRecord operation) and not removed from the cache automatically (there is no any sort of GC that runs in the background).

Constructors

Link copied to clipboard
constructor(nextCache: NormalizedCache? = null, maxSizeBytes: Int = Int.MAX_VALUE, expireAfterMillis: Long = -1)

Properties

Link copied to clipboard
val size: Int

Functions

Link copied to clipboard
open override fun clearAll()

Clears all records from the cache.

Link copied to clipboard
open override fun dump(): Map<KClass<*>, Map<String, Record>>
Link copied to clipboard
open override fun loadRecord(key: String, cacheHeaders: CacheHeaders): Record?
Link copied to clipboard
open override fun loadRecords(keys: Collection<String>, cacheHeaders: CacheHeaders): Collection<Record>

Calls through to NormalizedCache.loadRecord. Implementations should override this method if the underlying storage technology can offer an optimized manner to read multiple records. There is no guarantee on the order of returned Record

Link copied to clipboard
open override fun merge(record: Record, cacheHeaders: CacheHeaders, recordMerger: RecordMerger): Set<String>

open override fun merge(records: Collection<Record>, cacheHeaders: CacheHeaders, recordMerger: RecordMerger): Set<String>

Calls through to NormalizedCache.merge. Implementations should override this method if the underlying storage technology can offer an optimized manner to store multiple records.

Link copied to clipboard
open override fun remove(pattern: String): Int

Remove records whose key matches a given pattern from this cache and all chained caches

open override fun remove(cacheKey: CacheKey, cascade: Boolean): Boolean

Remove a record and potentially its referenced records from this cache and all chained caches