Data.CacheGeneric caching.
Use T.Cache module if you want to cache values of type T.t.
Use Data.Cache.digest to build digests of the data for caching.
create ~load ~save creates a cache provider.
val digest :
namespace:string ->
('a, Stdlib.Format.formatter, unit, digest) Core_kernel.format4 ->
'adigest ~namespace fmt x y z ... a variadic function to create data digests. Use it like a printf, e.g.,
type t = {name : string; parent : string; lang : string}
let digest t = Data.Cache.digest ~namespace:"student" "%s%s"
t.name t.parentIn the example, we created a digest that will ignore lang field of the data type (that is assumed to be transparent to the cached computation).
Note: digest function will first eagerly build the whole string and then convert it to the digest. So it has O(N) complexity in space and time, where N is the total size of all constituting elements. If N is too big (hundreds of megabytes) then use Digest module for building digests incrementally.
module Digest : sig ... endData digesting for caching.
load cls digest loads entry with a given digest from the cache. Note, this is a generic function, if you want to load a value of type T.t use T.Cache.load function.
save cls digest x stores entry x with a given digest to the cache. Note, this is a generic function, if you want to store a value of type T.t use T.Cache.save function.
module Service : sig ... endService injection point.