package ocsigenserver

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module OcsipersistSource

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

Sourcetype 'a t

Type of persistent data

Sourcetype store

Data are divided into stores. Create one store for your project, where you will save all your data.

Sourceval open_store : string -> store Lwt.t

Open a store (and create it if it does not exist)

Sourceval make_persistent : store:store -> name:string -> default:'a -> 'a t Lwt.t

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.

Sourceval 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

Sourceval make_persistent_lazy_lwt : store:store -> name:string -> default:(unit -> 'a Lwt.t) -> 'a t Lwt.t

Lwt version of make_persistent_lazy.

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

get pv gives the value of pv

Sourceval set : 'a t -> 'a -> unit Lwt.t

set pv value sets a persistent value pv to value

Persistent tables

Sourcetype internal
Sourcemodule type TABLE_CONF = sig ... end
Sourcemodule type COLUMN = sig ... end
Sourcemodule type TABLE = sig ... end
Sourcemodule Table (T : TABLE_CONF) (Key : COLUMN) (Value : COLUMN) : TABLE with type key = Key.t and type value = Value.t
Sourcemodule Column : sig ... end
Sourcetype 'value table

Type of persistent table

Sourceval table_name : 'value table -> string Lwt.t

returns the name of the table

Sourceval open_table : string -> 'value table Lwt.t

Open a table (and create it if it does not exist)

Sourceval find : 'value table -> string -> 'value Lwt.t

find table key gives the value associated to key. Fails with Not_found if not found.

Sourceval add : 'value table -> string -> 'value -> unit Lwt.t

add 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.

Sourceval replace_if_exists : 'value table -> string -> 'value -> unit Lwt.t

replace_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.

Sourceval remove : 'value table -> string -> unit Lwt.t

remove table key removes the entry in the table if it exists

Sourceval length : 'value table -> int Lwt.t

Size of a table.

Sourceval iter_step : (string -> 'a -> unit Lwt.t) -> 'a table -> unit Lwt.t

Important 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).

Sourceval iter_table : (string -> 'a -> unit Lwt.t) -> 'a table -> unit Lwt.t

Legacy interface for iter_step

Sourceval fold_step : (string -> 'a -> 'b -> 'b Lwt.t) -> 'a table -> 'b -> 'b Lwt.t

Important 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).

Sourceval fold_table : (string -> 'a -> 'b -> 'b Lwt.t) -> 'a table -> 'b -> 'b Lwt.t

Legacy interface for fold_step

OCaml

Innovation. Community. Security.