0
0
mirror of https://github.com/thunderbird/thunderbird-android.git synced 2024-09-20 12:12:15 +02:00

Move Cache to core common module

This commit is contained in:
Wolf Montwé 2023-02-28 17:37:31 +01:00
parent fab0749abd
commit 59541c0d6b
No known key found for this signature in database
GPG Key ID: 6D45B21512ACBF72
6 changed files with 19 additions and 12 deletions

View File

@ -1,4 +1,4 @@
package com.fsck.k9.cache
package app.k9mail.core.common.cache
interface Cache<KEY : Any, VALUE : Any> {

View File

@ -1,9 +1,9 @@
package com.fsck.k9.cache
package app.k9mail.core.common.cache
import kotlinx.datetime.Clock
import kotlinx.datetime.Instant
internal class ExpiringCache<KEY : Any, VALUE : Any>(
class ExpiringCache<KEY : Any, VALUE : Any>(
private val clock: Clock,
private val delegateCache: Cache<KEY, VALUE> = InMemoryCache(),
private var lastClearTime: Instant = clock.now(),

View File

@ -1,6 +1,6 @@
package com.fsck.k9.cache
package app.k9mail.core.common.cache
internal class InMemoryCache<KEY : Any, VALUE : Any>(
class InMemoryCache<KEY : Any, VALUE : Any>(
private val cache: MutableMap<KEY, VALUE> = mutableMapOf(),
) : Cache<KEY, VALUE> {
override fun get(key: KEY): VALUE? {

View File

@ -1,6 +1,6 @@
package com.fsck.k9.cache
package app.k9mail.core.common.cache
internal class SynchronizedCache<KEY : Any, VALUE : Any>(
class SynchronizedCache<KEY : Any, VALUE : Any>(
private val delegateCache: Cache<KEY, VALUE>,
) : Cache<KEY, VALUE> {

View File

@ -1,8 +1,12 @@
package com.fsck.k9.cache
package app.k9mail.core.common.cache
import app.k9mail.core.testing.TestClock
import com.google.common.truth.Truth.assertThat
import org.junit.Test
import assertk.assertThat
import assertk.assertions.isEqualTo
import assertk.assertions.isFalse
import assertk.assertions.isNull
import assertk.assertions.isTrue
import kotlin.test.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized

View File

@ -1,7 +1,10 @@
package com.fsck.k9.cache
package app.k9mail.core.common.cache
import app.k9mail.core.testing.TestClock
import com.google.common.truth.Truth.assertThat
import assertk.assertThat
import assertk.assertions.isEqualTo
import assertk.assertions.isFalse
import assertk.assertions.isNull
import kotlin.test.Test
import kotlin.time.Duration.Companion.milliseconds