An user-friendly, modular and secure key value storage.
// Create your kached instance
val cache = kached<String> {
logger = SimpleLogger()
serializer = GsonSerializer(Gson())
storage = SimpleMemoryStorage()
}
// Put some value
cache.set("foo", "bar")
// Get the value
cache.get("foo") // Returns value or null
// Remove value
cache.unset("foo")
// Clear cache
cache.clear()
+--------------------------+
| |
+------+ val data: T +<--------+
| | | |
| +--------------------------+ |
| |
v |
+-------------+------------+ +-------------+------------+
| | | |
| set(key, value) | | parse(decryptedValue) |
| | | |
+-------------+------------+ +-------------+------------+
| ^
| |
+-------------v------------+ +-------------+------------+
| | | |
| serialize(value) | | retrieveValue(key) |
| | | |
+-------------+------------+ +-------------+------------+
| ^
| |
+-------------v------------+ +-------------+------------+
| | | |
| encrypt(serialValue) | | decrypt(valueFromStore) |
| | | |
+-------------+------------+ +-------------+------------+
| ^
| |
+-------------v------------+ +-------------+------------+
| | | |
| store(encryptedValue) | | get(key) |
| | | |
+-------------+------------+ +-------------+------------+
| ^
| |
| +--------------------------+ |
| | | |
+------>+ cache_value +--------+
| |
+--------------------------+
// Add core dependency
implementation "io.kached:core:$version"
// Pick one serializer
implementation "io.kached:gson-serializer:$version"
// Pick one storage
implementation "io.kached:shared-prefs-storage:$version"
implementation "io.kached:file-storage:$version"
// [Optional] Choose one encryptor
// TODO: Implement encryption libs
// [Optional] Choose one logger
implementation "io.kached:simple-logger:$version"
implementation "io.kached:android-logger:$version"