DataCache

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
inline suspend fun <T : Any> DataCache.count(block: QueryBuilder<T>.() -> Unit = {}): Long

Returns the amount of values that match the block.

Link copied to clipboard
inline fun <T : Any> DataCache.find(block: QueryBuilder<T>.() -> Unit = {}): Query<T>

Creates a new Query configured with the block.

Link copied to clipboard
inline fun <T : Any> DataCache.flow(block: QueryBuilder<T>.() -> Unit = {}): Flow<T>

Executes a query with the block and returns the values as a Flow.

Link copied to clipboard
abstract fun <T : Any> getEntry(type: KType): DataEntryCache<T>?

Returns a DataEntryCache of the given type if its description was registered beforehand, null otherwise.

Link copied to clipboard
inline fun <T : Any> DataCache.getEntry(): DataEntryCache<T>?

Returns a DataEntryCache of the given T if its description was registered beforehand, null otherwise.

Link copied to clipboard
inline suspend fun <T : Any> DataCache.put(item: T): Unit?
suspend fun <T : Any> DataCache.put(type: KType, item: T): Unit?

Inserts a new item into the cache. Inserting an entry with an id that is already present will cause the old value to be overwritten.

inline suspend fun <VALUE : Any> DataCache.put(item: VALUE, ttl: Duration): Unit?

Inserts a new expiring item into the cache for ttl. Inserting an entry with an id that is already present will cause the old value to be overwritten.

inline suspend fun <VALUE : Any> DataCache.put(items: Iterable<VALUE>, ttl: Duration): Unit?
inline suspend fun <VALUE : Any> DataCache.put(items: Flow<VALUE>, ttl: Duration): Unit?

Inserts new expiring items into the cache for ttl. Inserting an entry with an id that is already present will cause the old value to be overwritten.

inline suspend fun <VALUE : Any> DataCache.put(item: VALUE, until: Instant, clock: Clock = Clock.System): Unit?

Inserts a new item into the cache until it expires. Inserting an entry with an id that is already present will cause the old value to be overwritten.

inline suspend fun <VALUE : Any> DataCache.put(items: Iterable<VALUE>, until: Instant, clock: Clock = Clock.System): Unit?
inline suspend fun <VALUE : Any> DataCache.put(items: Flow<VALUE>, until: Instant, clock: Clock = Clock.System): Unit?

Inserts new items into the cache until it expires. Inserting an entry with an id that is already present will cause the old value to be overwritten.

Link copied to clipboard
inline suspend fun <T : Any> DataCache.putAll(vararg items: T): Unit?
inline suspend fun <T : Any> DataCache.putAll(items: Iterable<T>): Unit?
inline suspend fun <T : Any> DataCache.putAll(items: Flow<T>): Unit?

Inserts all items into the cache. Inserting an entry with an id that is already present will cause the old value to be overwritten.

Link copied to clipboard
inline fun <T : Any> DataCache.query(block: QueryBuilder<T>.() -> Unit = {}): Query<T>

Creates a new Query configured with the block.

Link copied to clipboard
abstract suspend fun register(description: DataDescription<out Any, out Any>)

Registers a description and preforms the necessary setup to use the type of this class.

open suspend fun register(vararg descriptions: DataDescription<out Any, out Any>)
open suspend fun register(descriptions: Iterable<DataDescription<out Any, out Any>>)

Registers the descriptions and preforms the necessary setup to use the type of these classes.

Link copied to clipboard
inline suspend fun <T : Any> DataCache.remove(block: QueryBuilder<T>.() -> Unit = {})

Removes all the values that match the block.

Link copied to clipboard

Wraps this cache in a MetricsCache, enabling logging of metrics.