Module Ocsipersist


module Ocsipersist: sig .. end
Module Ocsipersist: persistent data in DBM database


Persistent references



When launching the program, if the value exists on hard disk, it is loaded, otherwise it is initialised to the default value
type 'a t 
Type of persistent data
type store 
Data are divided into stores. Create one store for your project, where you will save all your data.
val open_store : string -> store
Open a store (and create it if it does not exist)
val make_persistent : store:store ->
name:string -> default:'a -> 'a t Lwt.t
make_persistent store name default creates a persistent value named name in store store from database or create it with the default value default if it does not exist.
val make_persistent_lazy : store:store ->
name:string -> default:(unit -> 'a) -> 'a t Lwt.t
Same as make_persistent but the default value is evaluated only if needed
val get : 'a t -> 'a Lwt.t
get pv gives the value of pv
val set : 'a t -> 'a -> unit Lwt.t
set pv value sets a persistent value pv to value

Persistent tables


type 'a table 
Type of persistent table
val open_table : string -> 'a table
Open a table (and create it if it does not exist)
val find : 'a table -> string -> 'a Lwt.t
find table key gives the value associated to key. Raises Not_found if not found.
val add : 'a table -> string -> 'a -> unit Lwt.t
add table key value associates the value value to key key. If the database already contains data associated with key, that data is discarded and silently replaced by the new data.
val remove : 'a table -> string -> unit Lwt.t
remove table key removes the entry in the table if it exists