About
A key-value database / store is a NoSQL database based on the key-value data that is stored in
- or map data structure.
You store some data, called a value, inside a key. The data can later be retrieved by key.
Each value is not limited to primitive data type but also a complex one such as list, hashes.
Usage
- shopping cart
- session service.
List
Database
- Oracle NoSQL, Oracle Coherence
- Java:
- MapDb Java (JDBM)
- C:
- LevelDb and forks wiki/RocksDB)
- Berkeley DB (unmaintained) - high-performance embedded database for key/value data stored as byte arrays…
Cache library
Cache library may implement an on-disk representation (ie serialization, read-through, write-through). Be careful that you may not want any purge to happen.
There are 2 configurations/patterns:
- Cache-Aside: Check the cache for an entry, if empty, check the system-of-record
// Pseudocode for reading values
v = cache.get(k)
if(v == null) {
v = sor.get(k)
cache.put(k, v)
}
// Pseudocode for writing values
v = newV
sor.put(k, v)
cache.put(k, v)
- Cache-As-Sor: The cache is the system-of-record. The application accesses only the cache and the cache access the backend system-of-record via:
- read-through to load data
- write-through (sync) or write-behind (async) to write data
List:
- Java Map Cache:
- Ehcache 1)
- Not Caffeine. Caffeine is on-heap caching and does not offer persistence