Library
Module
Module type
Parameter
Class
Class type
Create an on-disk persistent version of the Hash_queue
data structure.
Parameters
module N : sig ... end
module K : Tezos_crypto.S.HASH
module V : sig ... end
Signature
val remove : t -> K.t -> unit Tezos_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 Tezos_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.
val length : t -> int
length q
is the number of bindings held by q
.
val load_from_disk :
warn_unreadable:
(string ->
Tezos_base.TzPervasives.error Tezos_base.TzPervasives.trace ->
unit Lwt.t)
option ->
capacity:int ->
data_dir:string ->
filter:(V.t -> bool) ->
t Tezos_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.