Disk_persistence.Make_queue
Create an on-disk persistent version of the Hash_queue
data structure.
module N : sig ... end
module K : Mavryk_crypto.Intfs.HASH
module V : sig ... end
val remove : t -> K.t -> unit Mavryk_base.TzPervasives.tzresult Lwt.t
remove q k
removes the binding from k
in q
. If k
is not bound in c
, it does nothing. The removal is persisted on disk.
val replace : t -> K.t -> V.t -> unit Mavryk_base.TzPervasives.tzresult Lwt.t
replace q k v
binds the key k
to the value v
in the queue q
. This may or may not cause another binding to be removed, depending on the number of bindings already present in q
. The addition (or replacement) is persisted on disk.
fold f q init
folds the function f
over the bindings of q
(in memory). The elements are iterated from oldest to newest.
find_opt q k
is Some v
if k
is bound to v
in q
. It is None
otherwise.
val length : t -> int
length q
is the number of bindings held by q
.
val clear : t -> unit Lwt.t
clear q
empties the queue q
and removes its persistent content on disk.
val load_from_disk :
warn_unreadable:
(string ->
Mavryk_base.TzPervasives.error Mavryk_base.TzPervasives.trace ->
unit Lwt.t)
option ->
capacity:int ->
data_dir:string ->
filter:(V.t -> bool) ->
t Mavryk_base.TzPervasives.tzresult Lwt.t
load_from_disk ~warn_unreadable ~capacity ~data_dir ~filter
creates a bounded hash queue of capacity capacity
. The queue is populated by persistent elements present in data_dir/N.name
which pass the filter
(the directory is created if it does not exist). If warn_unreadable
is Some warn
, unreadable files are ignored but a warning is printed with warn
, otherwise the loading fails on the first unreadable file.