Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.dropbox.android.external.cache4

import java.util.concurrent.TimeUnit
import kotlin.time.Duration
import kotlin.time.ExperimentalTime
import kotlin.time.toDuration

/**
* An in-memory key-value store with support for time-based (expiration) and size-based evictions.
Expand Down Expand Up @@ -123,10 +125,13 @@ interface Cache<in Key : Any, Value : Any> {
*/
internal class CacheBuilderImpl : Cache.Builder {

// Ideally these would be set to Duration.INFINITE, but this breaks consumers compiling with
// Kotlin 1.4-M3 (not sure why).
// TODO: revert back to using Duration.INFINITE once Store is compiled with Kotlin 1.4
@ExperimentalTime
private var expireAfterWriteDuration = Duration.INFINITE
private var expireAfterWriteDuration = Double.POSITIVE_INFINITY.toDuration(TimeUnit.SECONDS)
@ExperimentalTime
private var expireAfterAccessDuration = Duration.INFINITE
private var expireAfterAccessDuration = Double.POSITIVE_INFINITY.toDuration(TimeUnit.SECONDS)
private var maxSize = UNSET_LONG
private var concurrencyLevel = DEFAULT_CONCURRENCY_LEVEL
private var clock: Clock? = null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.dropbox.android.external.store4

import java.util.concurrent.TimeUnit
import kotlin.time.Duration
import kotlin.time.ExperimentalTime
import kotlin.time.toDuration

/**
* MemoryPolicy holds all required info to create MemoryCache
Expand Down Expand Up @@ -67,7 +69,10 @@ class MemoryPolicy internal constructor(
}

companion object {
val DEFAULT_DURATION_POLICY: Duration = Duration.INFINITE
// Ideally this would be set to Duration.INFINITE, but this breaks consumers compiling with
// Kotlin 1.4-M3 (not sure why).
// TODO: revert back to using Duration.INFINITE once Store is compiled with Kotlin 1.4
val DEFAULT_DURATION_POLICY: Duration = Double.POSITIVE_INFINITY.toDuration(TimeUnit.SECONDS)
const val DEFAULT_SIZE_POLICY: Long = -1

fun builder(): MemoryPolicyBuilder = MemoryPolicyBuilder()
Expand Down