package ocsigenserver
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=acb09f06430cb8eefd83a849af6450af
sha512=f2c5111a02989572a19706ca5238d3740c4c06d97b0e1791ae0e06665666574ada94421d10edee636042984ab9df6357b4febbb4edc34b01e72619027b95bfec
doc/ocsipersistdbm/Ocsipersist/index.html
Module Ocsipersist
Persistent data on hard disk.
There are currently three implementations of this module, one using a DBM database, on the PostgreSQL database, and one using SQLITE. Link the one your want with your program.
Persistent references
When launching the program, if the value exists on hard disk, it is loaded, otherwise it is initialised to the default value
Data are divided into stores. Create one store for your project, where you will save all your data.
val open_store : string -> store Lwt.tOpen a store (and create it if it does not exist)
make_persistent store name default find a persistent value named name in store store from database, or create it with the default value default if it does not exist.
Same as make_persistent but the default value is evaluated only if needed
val make_persistent_lazy_lwt :
store:store ->
name:string ->
default:(unit -> 'a Lwt.t) ->
'a t Lwt.tLwt version of make_persistent_lazy.
val get : 'a t -> 'a Lwt.tget pv gives the value of pv
val set : 'a t -> 'a -> unit Lwt.tset pv value sets a persistent value pv to value
Persistent tables
module type TABLE_CONF = sig ... endmodule type COLUMN = sig ... endmodule type TABLE = sig ... endmodule Column : sig ... endval table_name : 'value table -> string Lwt.treturns the name of the table
val open_table : string -> 'value table Lwt.tOpen a table (and create it if it does not exist)
val find : 'value table -> string -> 'value Lwt.tfind table key gives the value associated to key. Fails with Not_found if not found.
val add : 'value table -> string -> 'value -> unit Lwt.tadd table key value associates value to key. If the database already contains data associated with key, that data is discarded and silently replaced by the new data.
val replace_if_exists : 'value table -> string -> 'value -> unit Lwt.treplace_if_exists table key value associates value to key only if key is already bound. If the database does not contain any data associated with key, fails with Not_found.
val remove : 'value table -> string -> unit Lwt.tremove table key removes the entry in the table if it exists
val length : 'value table -> int Lwt.tSize of a table.
val iter_step : (string -> 'a -> unit Lwt.t) -> 'a table -> unit Lwt.tImportant warning: this iterator may not iter on all data of the table if another thread is modifying it in the same time. Nonetheless, it should not miss more than a very few data from time to time, except if the table is very old (at least 9 223 372 036 854 775 807 insertions).
val iter_table : (string -> 'a -> unit Lwt.t) -> 'a table -> unit Lwt.tLegacy interface for iter_step
val fold_step : (string -> 'a -> 'b -> 'b Lwt.t) -> 'a table -> 'b -> 'b Lwt.tImportant warning: this iterator may not iter on all data of the table if another thread is modifying it in the same time. Nonetheless, it should not miss more than a very few data from time to time, except if the table is very old (at least 9 223 372 036 854 775 807 insertions).
val fold_table : (string -> 'a -> 'b -> 'b Lwt.t) -> 'a table -> 'b -> 'b Lwt.tLegacy interface for fold_step