Remove deprecated code to fix error when users upgrade to kotlin 1.5 (#265)

* upgrade to kotlin 1.5 warning breaking change

* achieve compatibility with 1.4 and 1.5

* trigger travis

* fix lint

Co-authored-by: miken <miken@dropbox.com>
This commit is contained in:
Mike Nakhimovich 2021-05-06 11:45:17 -04:00 committed by GitHub
parent 1187b944bb
commit 35fd9af24f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 6 deletions

View file

@ -282,7 +282,7 @@ StoreBuilder
The following will clear the entry associated with the key from both the in-memory cache and the sourceOfTruth:
```kotlin
store.clear("10")
store.clear("myKey")
```
The following will clear all entries from both the in-memory cache and the sourceOfTruth:

View file

@ -9,6 +9,7 @@ import java.io.File
import java.io.FileNotFoundException
import java.io.IOException
import kotlin.time.Duration
import kotlin.time.DurationUnit
import kotlin.time.ExperimentalTime
/**
@ -74,7 +75,7 @@ internal class FileSystemImpl(private val root: File) : FileSystem {
return RecordState.MISSING
}
val now = System.currentTimeMillis()
val cuttOffPoint = now - expirationDuration.toLongMilliseconds()
val cuttOffPoint = now - expirationDuration.toLong(DurationUnit.MILLISECONDS)
return if (file.lastModified() < cuttOffPoint) {
RecordState.STALE
} else {

View file

@ -1,8 +1,9 @@
package com.dropbox.android.external.store4
import kotlin.time.Duration
import kotlin.time.DurationUnit
import kotlin.time.ExperimentalTime
import kotlin.time.hours
import kotlin.time.toDuration
@ExperimentalTime
internal object StoreDefaults {
@ -12,7 +13,7 @@ internal object StoreDefaults {
*
* @return memory cache TTL
*/
val cacheTTL: Duration = 24.hours
val cacheTTL: Duration = 24.toDuration(DurationUnit.HOURS)
/**
* Cache size (default is 100), can be overridden

View file

@ -38,6 +38,7 @@ import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.transform
import java.util.concurrent.TimeUnit
import kotlin.time.DurationUnit
import kotlin.time.ExperimentalTime
@ExperimentalTime
@ -65,13 +66,13 @@ internal class RealStore<Key : Any, Input : Any, Output : Any>(
CacheBuilder.newBuilder().apply {
if (memoryPolicy.hasAccessPolicy) {
expireAfterAccess(
memoryPolicy.expireAfterAccess.toLongMilliseconds(),
memoryPolicy.expireAfterAccess.toLong(DurationUnit.MILLISECONDS),
TimeUnit.MILLISECONDS
)
}
if (memoryPolicy.hasWritePolicy) {
expireAfterWrite(
memoryPolicy.expireAfterWrite.toLongMilliseconds(),
memoryPolicy.expireAfterWrite.toLong(DurationUnit.MILLISECONDS),
TimeUnit.MILLISECONDS
)
}