Package-level declarations

Types

Link copied to clipboard
expect class ConcurrentHashMap<K, V> : MutableMap<K, V>
actual typealias ConcurrentHashMap<K, V> = ConcurrentMutableMap<K, V>
Link copied to clipboard
interface DataCache
Link copied to clipboard
interface DataEntryCache<VALUE : Any>

A cache for a single type VALUE.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.PROPERTY])
annotation class Identity

Creates a IndexField for the given class, DataCaches can use this field to efficiently index entities for queries on this field. Only one Identity field is allowed per class.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.PROPERTY])
annotation class Link(val to: KClass<*>, val name: String)

Creates a one-way link with the to class on the name field, meaning that upon the removal of an entity of the annotated class, all entities of the to class with a name field value equal to this annotated field will also be removed.

Link copied to clipboard
interface Query<T : Any>

A lazy query. Functions in this class should be handled as if they are operating on cold Flows.

Link copied to clipboard
interface QueryBuilder<T : Any>

A builder containing predicates to filter data with.

Functions

Link copied to clipboard
inline suspend fun <T : Any> DataCache.count(block: QueryBuilder<T>.() -> Unit = {}): Long
inline suspend fun <T : Any> DataEntryCache<T>.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>
inline fun <T : Any> DataEntryCache<T>.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>
inline fun <T : Any> DataEntryCache<T>.flow(block: QueryBuilder<T>.() -> Unit = {}): Flow<T>

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

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.

Link copied to clipboard
inline suspend fun <T : Any> DataCache.putAll(vararg items: T): <Error class: unknown class>?
inline suspend fun <T : Any> DataCache.putAll(items: Iterable<T>): <Error class: unknown class>?
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>
inline fun <T : Any> DataEntryCache<T>.query(block: QueryBuilder<T>.() -> Unit = {}): Query<T>

Creates a new Query configured with the block.

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

Removes all the values that match the block.