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

commonMain.com.apollographql.execution.InMemoryPersistedDocumentCache.kt Maven / Gradle / Ivy

package com.apollographql.execution

import com.apollographql.execution.internal.LruCache
import kotlinx.atomicfu.locks.reentrantLock
import kotlinx.atomicfu.locks.withLock

class InMemoryPersistedDocumentCache: PersistedDocumentCache {
    private val lock = reentrantLock()
    private val lruCache = LruCache(100)

    override fun get(id: String): PersistedDocument? {
        return lock.withLock {
            lruCache.get(id)
        }
    }

    override fun put(id: String, persistedDocument: PersistedDocument) {
        return lock.withLock {
            lruCache.set(id, persistedDocument)
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy