softmemory
This library is my solution of "Create 2 lvl cache" problem on Java 8.
A complete statement is
Create a configurable two-level cache (for caching Objects). Level 1 is memory, level 2 is filesystem. Config params should let one specify the cache strategies and max sizes of level 1 and 2.
My solution is based on 3 abstractions:
Memory<K, V>
- simple associative container interface;Cache<K, V>
- cache replacement policies overMemory<K, V>
buffer;CachedMemory<K, V>
- extended fromMemory<K, V>
cache writing policies overMemory<K, V>
main memory andCache<K, V>
buffer.
This approach makes possible to create any depth-level cache by using object of CachedMemory
as buffer for Cache
.
Possible 3 level case is:
- In memory storage;
- Filesystem storage;
- Remote storage.
Finally, interface-based design makes library easily extensible for custom realization of replacement and writing policies.