AnyCache

class AnyCache<V : Any>(wrapped: Cache<V>) : Cache<V>

A type-forwarding wrapper around an arbitrary Cache.

Provided for API symmetry with SwiftyNetwork's AnyCache. Unlike Swift, Kotlin generics are not erased at the type level, so a Cache<V> is already usable as an abstract type — this class is a thin convenience for callers that want a concrete, non-generic-parameter-leaking cache handle. Implemented via interface delegation.

Constructors

Link copied to clipboard
constructor(wrapped: Cache<V>)

Functions

Link copied to clipboard
open override 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 override fun entry(key: CacheKey): CacheEntry<V>?

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

Link copied to clipboard
open suspend override fun removeAll()

Removes every entry.

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

Removes any value stored for key.

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

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

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

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

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

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