package weberizer
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Module Weberizer.Cache
Source
Simple cache with dependencies and timeout.
A cache for elements of type 'a.
val make :
?dep:'b t ->
?new_if:('a t -> bool) ->
?timeout:float ->
?debug:bool ->
string ->
('a option -> 'a) ->
'a t
make key f
create a new cache to hold the return value of f
using the key
. f
is given its previously returned value if any — it may be less work to update it than recreating it afresh. The disk cache will be updated when the program exits, so its content will persist across multiplie runs of the program. The type 'a
must be marshal-able.
update t
update the cache immediately. If f
is given, first set the function generating values for the cache t
to f
and then update the cache by running f
.
depend t t'
says that the cache t
depends on the cache t'
i.e. that before updating t
, one must update t'
.
Get the value stored in the cache. This operation will update the cached value if necessary.
val result :
?dep:'b t ->
?new_if:('a t -> bool) ->
?timeout:float ->
?debug:bool ->
string ->
('a option -> 'a) ->
'a
result key f
is a convenience function equivalent to get(make key f)
.
The time of the last update of the cache. Returns neg_infinity
if the cache is not initialized.