Store/cache
Matt Ramotar 74bb49ddb5
Migrate to version catalogs (#561)
Signed-off-by: Matt Ramotar <mramotar@dropbox.com>
2023-07-05 18:31:37 -04:00
..
src Make it easier to work with lists (#548) 2023-05-19 16:41:42 -04:00
build.gradle.kts Migrate to version catalogs (#561) 2023-07-05 18:31:37 -04:00
gradle.properties [Store5] Target Android, iOS, JVM, JS (#493) 2023-01-16 16:31:12 -05:00
README.md [Store5] Target Android, iOS, JVM, JS (#493) 2023-01-16 16:31:12 -05:00

Cache

Store depends on a subset of Guava. This is a shaded artifact that is Kotlin Multiplatform compatible.

Usage

implementation("org.mobilenativefoundation.store:cache:${STORE_VERSION}")

Implementation

Model the key

data class Key(
    val id: String
)

Model the value

data class Post(
    val title: String
)

Build the cache

 val cache = CacheBuilder<Key, Post>()
    .maximumSize(100)
    .expireAfterWrite(1.day)
    .build()

See Also

https://github.com/google/guava/wiki/CachesExplained

License

Copyright (c) 2017 The New York Times Company

Copyright (c) 2010 The Guava Authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this library except in 
compliance with the License. You may obtain a copy of the License at

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 
language governing permissions and limitations under the License.