Module Brr_note_legacy.Store
Persistent storage.
Persisent key-value store implemented over webstorage. Safe if no one tampers with the storage outside of the program.
XXX.
- This still relies on the jsoo representation, add safer keys with type indexed codecs.
- Provide something sensitive for storage events
Storage scope
Keys
val key : ?ns:Jstr.t -> unit -> 'a key
key ~ns ()
is a new storage key in namespacens
. Ifns
is unspecified, the key lives in a global namespace.Warning. Reordering invocations of
key
in the same namespace will most of the time corrupt existing storage. This means that allkey
calls should always be performed at initialization time.Store.force_version
can be used to easily version your store and aleviate this problem.
Storage
In the functions below scope
defaults to `Persist
.
val get : ?scope:scope -> ?absent:'a -> 'a key -> 'a
get k
isk
's mapping. Ifabsent
is provided andm
has not binding fork
,absent
is returned.- raises Invalid_argument
if
k
is not bound andabsent
is unspecified or ifscope
is notsupport
ed.
val clear : ?scope:scope -> unit -> unit
clear ()
, clears all mapping.