https://github.com/beapp/beapp.library.cache.android
This library provides a cache mechanism relying on RxJava.
https://github.com/beapp/beapp.library.cache.android
android cache paperdb rx snappydb
Last synced: 8 months ago
JSON representation
This library provides a cache mechanism relying on RxJava.
- Host: GitHub
- URL: https://github.com/beapp/beapp.library.cache.android
- Owner: BeApp
- License: apache-2.0
- Created: 2020-01-22T13:17:51.000Z (over 6 years ago)
- Default Branch: develop
- Last Pushed: 2020-02-21T16:18:02.000Z (over 6 years ago)
- Last Synced: 2025-07-29T08:42:08.242Z (11 months ago)
- Topics: android, cache, paperdb, rx, snappydb
- Homepage:
- Size: 214 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This library provides a cache mechanism relying on [RxJava](https://github.com/ReactiveX/RxJava).
There are currently two storage implementation :
* [SnappyDb](https://github.com/nhachicha/SnappyDB)
* [PaperDb](https://github.com/pilgr/Paper)
# Usage
Two steps are needed :
1. Prepare an instance of your storage implementation
2. Declare an instance of RxCache with the storage implementation
3. Call `fromKey` method from RxCache instance and configure the strategy for this call
```java
final Storage storage = new SnappyDBStorage();
final RxCache rxCache = new RxCache(storage);
rxCache.fromKey("remotedata_%d", 1)
.withStrategy(CacheStrategy.cacheThenAsync())
.withAsync(...) // Your async observable method (Retrofit call for example)
.toObservable()
.subscribe(result -> ...,
throwable -> ...);
```
# Installation
Add jcenter's repository in your project's repositories list, then add the dependency.
```groovy
repositories {
jcenter()
}
dependencies {
implementation 'fr.beapp.cache:cache-core:'
// Pick one of the following
implementation 'fr.beapp.cache:cache-storage-snappydb:'
implementation 'fr.beapp.cache:cache-storage-paperdb:'
}
```