[ANN] Ocsipersist 2.1.0: type-safe persistent references with Deriving

Ocsipersist 2.1.0 is out. Persistent references, stores and tables can now be serialised with Deriving_Json instead of Marshal: the data is human-readable in the database and stable across OCaml versions. The new API is fully backward compatible, and Ocsipersist works as a standalone library for any OCaml program (no Eliom or Ocsigen Server required).

type user = { name : string; age : int } [@@deriving json]

(* a persistent reference, stored as readable JSON *)
let visits = Ocsipersist.Ref_json.ref ~persistent:"visits" [%json: int] 0

let count_visit () =
  let%lwt n = Ocsipersist.Ref_json.get visits in
  Ocsipersist.Ref_json.set visits (n + 1)

Full announcement: Ocsipersist 2.1.0: type-safe persistence with Deriving — Ocsigen

3 Likes