package chamelon
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=4b56bfe8cc25585ddaee3cda1049e7541b63f730674744d14d762a8ee14b34e4
sha512=e715cb666cc885a9e179d466c1444b79e5c6f53a167fe6af9e3d567fd2c1c181f6e68b50386f6db1423a0032fca25e4620a94e94aa4c0ab22bc016b7c6827ae8
doc/chamelon.kv/Kv/Make/index.html
Module Kv.Make
Source
Parameters
module Sectors : Mirage_block.S
module Clock : Mirage_clock.PCLOCK
Signature
include Mirage_kv.RW
Read-write Stores
There is a trade-off between durability and performance. If you want performance, use the batch
operation with a chain of sets and removes. They will be applied on the underlying storage layer all at once. Otherwise set
and remove
will cause a flush in the underlying storage layer every time, which could degrade performance.
include Mirage_kv.RO
Read-only key-value stores
The type for errors.
The type representing the internal state of the key-value store.
Disconnect from the key-value store. While this might take some time to complete, it can never result in an error.
The type for keys.
exists t k
is Some `Value
if k
is bound to a value in t
, Some `Dictionary
if k
is a prefix of a valid key in t
and None
if no key with that prefix exists in t
.
exists
answers two questions: does the key exist and is it referring to a value or a dictionary.
An error occurs when the underlying storage layer fails.
get t k
is the value bound to k
in t
.
The result is Error (`Value_expected k)
if k
refers to a dictionary in t
.
list t k
is the list of entries and their types in the dictionary referenced by k
in t
.
The result is Error (`Dictionary_expected k)
if k
refers to a value in t
.
last_modified t k
is the last time the value bound to k
in t
has been modified.
The modification time (d, ps)
is a span for the signed POSIX picosecond span d
* 86_400e12 + ps
. d
is a signed number of POSIX days and ps
a number of picoseconds in the range [0
;86_399_999_999_999_999L
].
When the value bound to k
is a dictionary, the modification time is the latest modification of all entries in that dictionary. This behaviour is only one level deep and not recursive.
The type for write errors.
The pretty-printer for pp_write_error
.
set t k v
replaces the binding k -> v
in t
.
Durability is guaranteed unless set
is run inside an enclosing batch
operation, where durability will be guaranteed at the end of the batch.
remove t k
removes any binding of k
in t
. If k
was bound to a dictionary, the full dictionary will be removed.
Durability is guaranteed unless remove
is run inside an enclosing batch
operation, where durability will be guaranteed at the end of the batch.
batch t f
run f
in batch. Ensure the durability of operations.
Since a batch is applied at once, the readings inside a batch will return the state before the entire batch. Concurrent operations will not affect other ones executed during the batch.
Batch applications can fail to apply if other operations are happening concurrently. In case of failure, f
will run again with the most recent version of t
. The result is Error `Too_many_retries
if f
is run for more then retries
attemps (default is 13
).
get_partial t k ~offset ~length
gives errors for length 0, negative offsets and lengths, and partial reads off the end of the file. get_partial t k ~offset ~length
should always give a result of (Ok v) where String.length v = length, or an error.