Skip to content

Commit

Permalink
[Caching] make MultiKeyCacheConverter.kt fun interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
agrosner committed Feb 17, 2021
1 parent 86a1fa8 commit 209e682
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.dbflow5.structure.Model
* interface "zips" the complex primary keys into one "representative" key. Also this can be used to
* override the default caching key and provide a custom key.
*/
interface MultiKeyCacheConverter<out CacheKeyType> {
fun interface MultiKeyCacheConverter<out CacheKeyType> {

/**
* Converts the array of values into a singular representative key. The values are in order
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ class Coordinate(@PrimaryKey var latitude: Double = 0.0,
companion object {
@JvmField
@MultiCacheField
val cacheConverter = object : MultiKeyCacheConverter<String> {
override fun getCachingKey(values: Array<Any>) = "${values[0]},${values[1]}"
}
val cacheConverter = MultiKeyCacheConverter { values -> "${values[0]},${values[1]}" }
}
}

Expand Down

0 comments on commit 209e682

Please sign in to comment.