An implementation of core.cache
that saves entries to disk.
You get a chance to use LevelDB (default) or LMDB.
DISCLAIMER typical core.cache
implementations use persistent
and associative data structures. Since a disk-backed key-value
store doesn't have any such concept, this implementation might
not conform to expected behavior.
Import this implementation:
user> (use 'fort-knox.core :reload-all)
nil
Create a cache (LevelDB by default):
user> (def cache (make-cache "/tmp"))
#'user/cache
If you want to use LMDB:
user> (def cache (make-cache "/tmp" :type :lmdb))
#'user/cache
Everything else is from core.cache
. For example:
user> (cache/has? cache "foo")
false
user> (cache/miss cache "foo" "bar")
{:env #object[org.fusesource.lmdbjni.Env 0x6e09d885 "org.fusesource.lmdbjni.Env@6e09d885"], :db #object[org.fusesource.lmdbjni.Database 0x65807b47 "org.fusesource.lmdbjni.Database@65807b47"]}
user> (cache/has? cache "foo")
true
Copyright © 2016 Shriphani Palakodety
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.