All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.dev.kord.cache.map.internal.MapEntryCache.kt Maven / Gradle / Ivy

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