Module Ocsipersist.Store_json
Type-safe variable store using Deriving_Json for serialisation. Unlike Store, this does not rely on Stdlib.Marshal and is safe across OCaml versions. Requires types annotated with [@@deriving json] (from js_of_ocaml-ppx_deriving_json).
Note: The dependency on js_of_ocaml is only for the Deriving_Json runtime library, which provides type-safe JSON serialisation. This is the same serialisation mechanism used by Eliom for client-server communication. No JavaScript compilation is involved.
type 'a tType of persistent data
type storeData 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)
val make_persistent :
store:store ->
name:string ->
json:'a Deriving_Json.t ->
default:'a ->
'a t Lwt.tmake_persistent ~store ~name ~json ~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. Uses Deriving_Json for type-safe serialisation.
val make_persistent_lazy :
store:store ->
name:string ->
json:'a Deriving_Json.t ->
default:(unit -> 'a) ->
'a t Lwt.tSame as make_persistent but the default value is evaluated only if needed
val make_persistent_lazy_lwt :
store:store ->
name:string ->
json:'a Deriving_Json.t ->
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