TimestampedCache

interface TimestampedCache<V : Any> : Cache<V>

A Cache that lets callers supply an explicit timestamp when writing, so values promoted between cache layers can keep their original age. Mirrors SwiftyNetwork's TimestampedCache.

Inheritors

Functions

Link copied to clipboard
open fun changes(): Flow<CacheChange>

A hot stream of CacheChanges for this cache. The default is an empty flow, so caches that cannot observe mutations are simply non-reactive; observable caches override this.

Link copied to clipboard
open suspend fun entry(key: CacheKey): CacheEntry<V>?

Atomically returns the value and its timestamp for key, or null if absent.

Link copied to clipboard
abstract suspend fun removeAll()

Removes every entry.

Link copied to clipboard
abstract suspend fun removeValue(key: CacheKey)

Removes any value stored for key.

Link copied to clipboard
abstract suspend fun setValue(value: V, key: CacheKey)

Stores value for key, stamping it with the current time.

abstract suspend fun setValue(value: V, key: CacheKey, timestamp: Long)

Stores value for key stamped with the given epoch-millisecond timestamp.

Link copied to clipboard
abstract suspend fun timestamp(key: CacheKey): Long?

Returns the epoch-millisecond timestamp recorded for key, or null if absent.

Link copied to clipboard
abstract suspend fun value(key: CacheKey): V?

Returns the value stored for key, or null if absent.