StorageDelegate

class StorageDelegate<T : Any>(delegate: Storage<T>, cacheStrategy: CacheStrategy = CacheStrategy.NO_CACHE) : Storage<T>

A storage class that delegates its operations to a repository. It can optionally cache the stored item in memory.

Parameters

T

The type of the object to be stored.

delegate

The repository to delegate the operations to.

cacheStrategy

The strategy for caching the item in memory.

Constructors

Link copied to clipboard
constructor(delegate: Storage<T>, cacheStrategy: CacheStrategy = CacheStrategy.NO_CACHE)

Functions

Link copied to clipboard
open suspend override fun delete()

Deletes the item from the repository and removes it from memory if it's cached.

Link copied to clipboard
open suspend override fun get(): T?

Retrieves the item from memory if it's cached, otherwise from the repository.

Link copied to clipboard
open suspend override fun save(item: T)

Saves the given item in the repository and optionally in memory.