module Cache: Cache
val memoize : ?destruct:('b -> unit) ->
?expire:[ `Keep_all | `Keep_one | `Lru of int ] -> ('a -> 'b) -> 'a -> 'b
memoize ~destruct ~expire f
memoizes the results of f
.destruct
: function called on every value we remove from the cacheexpire
: Strategy used to prune out values from the cache`Keep_one
: only keeps the last result around`Keep_all
: (the default value) never delete any values from the cache`Lru n
: keep n
values in the cache and them removes the least recently
usedval unit : (unit -> 'a) -> unit -> 'a
These modules implement memoization and give you access to the cache. This,
for instance, enables you to flush it.
module Lru:sig
..end
module Keep_all:sig
..end
This enables you to implement your own caching strategy and store.
Generic caching is based on separating the replacement policie and the
store and tying them together with Make
.
module type Strategy =sig
..end
module type Store =sig
..end
module type S =sig
..end
Cache.Make
module Strategy:sig
..end
module Store:sig
..end
module Make(
Strat
:
Strategy
)
(
Store
:
Store
)
:S
with type 'a with_init_args = ('a Store.with_init_args Strat.with_init_args)