Cache.S
Aside from make
and access
, the rest of the functions in this interface are similar to the ones in Hashtbl
, so you can use those as a reference.
val access : 'a t -> ('a Table.t -> 'b) -> 'b Lwt.t
access(cache, f)
runs the function f
on the hash table contents of the cache
, returning the result value. It can be used to both read from and write to the cache.
f(table)
is a callback which has locked access to the hash table
contained in the cache
and can do anything with it, including multiple operations like checking if the cache contains a key, then adding it or not.
Since this does lock the cache, it is preferable to not do long-running operations here, and to finish and unlock as quickly as possible.
val length : 'a t -> int Lwt.t
val make : unit -> 'a t
make()
allocates a new cache value.
val reset : 'a t -> unit Lwt.t