package tezos-store

  1. Overview
  2. Docs

Persistent data manager.

Every data read/write operation is protected by a mutex preventing concurrent data-races.

type 'a t

The type for the persistent data.

val get : 'a t -> 'a Lwt.t

get data accesses the data (cached).

val write : 'a t -> 'a -> (unit, Tezos_error_monad.TzCore.error list) Stdlib.result Lwt.t

write data value overwrites the previous data with the new value.

val write_file : ('kind, 'a) Naming.encoded_file -> 'a -> (unit, Tezos_error_monad.TzCore.error list) Stdlib.result Lwt.t

write_file encoded_file value raw writes the encoded_file with the value.

Warning this function should not be used in a normal context as it aims to overwrite the target without preserving data races. Favour the usage of write.

val update_with : 'a t -> ('a -> 'a Lwt.t) -> (unit, Tezos_error_monad.TzCore.error list) Stdlib.result Lwt.t

update_with data f atomically updates data with the result of the application of f. Concurrent accesses to the data will block until the value is updated.

Warning Calling read/write in f will result in a deadlock.

val load : ('kind, 'a) Naming.encoded_file -> ('a t, Tezos_error_monad.TzCore.error list) Stdlib.result Lwt.t

load encoded_file loads and decode a data from an encoded_file.

val init : ('kind, 'a) Naming.encoded_file -> initial_data:'a -> ('a t, Tezos_error_monad.TzCore.error list) Stdlib.result Lwt.t

init encoded_file ~initial_data creates or load an on-disk data. If the file already exists, then the data is read from the file. Otherwise, initial_data is used.

OCaml

Innovation. Community. Security.