Store/cache
mnakhimovich fee0bccde7 [Store5] Target Android, iOS, JVM, JS (#493)
* [Temp] Remove all modules

* Remove references to Store 4

* Update CHANGELOG

* Update README

* Add Store 5 foundation
Co-authored-by: Andre Claßen <aclassen@users.noreply.github.com>
Co-authored-by: Mike Nakhimovich <mnakhimovich@Mikes-MBP.localdomain>
2023-01-16 16:31:12 -05:00
..
src [Store5] Target Android, iOS, JVM, JS (#493) 2023-01-16 16:31:12 -05:00
build.gradle.kts [Store5] Target Android, iOS, JVM, JS (#493) 2023-01-16 16:31:12 -05: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.