commonMain.dev.kord.cache.map.internal.MapEntryCache.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cache-map-jvm Show documentation
Show all versions of cache-map-jvm Show documentation
Adaptable cache with query-like operations
The newest version!
package dev.kord.cache.map.internal
import dev.kord.cache.api.DataCache
import dev.kord.cache.api.DataEntryCache
import dev.kord.cache.api.QueryBuilder
import dev.kord.cache.api.data.DataDescription
import dev.kord.cache.map.MapLikeCollection
/**
* a [DataEntryCache] that uses a [collection] to store and query its values.
*/
class MapEntryCache(
private val cache: DataCache,
private val description: DataDescription,
private val collection: MapLikeCollection
) : DataEntryCache {
override suspend fun put(item: VALUE) {
val key = description.indexField.property.get(item)
collection.put(key, item)
}
override fun query(): QueryBuilder = KeyValueQueryBuilder(cache, collection, description)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy