A lightweight and simple library to cache any serializable objects, using the LRU algorithm, two storage levels (files, memory), encryption and life cycle.
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url "https://jitpack.io"}
}
}
Add the dependency:
dependencies {
implementation 'com.github.kernel0x:falcon:1.0.2'
}
Create an object using the builder.
Cache<Object> cache = new Cache.Builder().build(getContext());
OR with special type
Cache<Cat> cache = new Cache.Builder().build(getContext());
Available methods in the Builder
- defaultLifetime default cache lifetime
- maxSize maximum cache size (file and ram)
- caseSensitiveKeys key case sensitivity
- autoCleanup auto clean timer time
- dualCacheMode caching mode
- encryptStrategy encryption algorithm
Everything is simple. Now you can cache something. Important! Cached objects must implement Serializable
cache.set(KEY, new Cat());
cache.set(KEY, new Cat(), DualCacheMode.ONLY_DISK);
cache.set(KEY, new Cat(), DualCacheMode.ONLY_RAM);
cache.set(KEY, new Cat(), new Duration(1, TimeUnit.SECONDS));
- encryption
- cache location selection (file or memory)
- LRU, cache extrusion method
- cache lifetime selection
- thread safe
It's totally tested. Check the tests! 😉
Checkout the Releases tab for all release info.