package irmin

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

Create views.

Parameters

module S : S

Signature

Views

type db = S.t

The type for store handles.

A view is a read-write temporary store, mirroring the main store.

include HRW with type key = S.Key.t with type value = S.Val.t

Hierarchical read-write stores

Hierarchical read-write stores are read-write stores using paths as keys. They are a very simplified abstraction of filesystems.

include RW with type key = S.Key.t with type value = S.Val.t

Read-write stores

include RO with type key = S.Key.t with type value = S.Val.t

Read-only stores

type t

Type for stores.

type key = S.Key.t

Type for keys.

type value = S.Val.t

Type for values.

val read : t -> key -> value option Lwt.t

Read a value from the store.

val read_exn : t -> key -> value Lwt.t

Same as read but raise Invalid_argument if the key does not exist.

val mem : t -> key -> bool Lwt.t

Check if a key exists.

val iter : t -> (key -> value Lwt.t -> unit Lwt.t) -> unit Lwt.t

iter t fn call the function fn on all t's keys and values.

val update : t -> key -> value -> unit Lwt.t

update t k v replaces the contents of k by v in t. If k is not already defined in t, create a fresh binding. Raise Invalid_argument if k is the empty path.

val compare_and_set : t -> key -> test:value option -> set:value option -> bool Lwt.t

compare_and_set t key ~test ~set sets key to set only if the current value of key is test and in that case returns true. If the current value of key is different, it returns false. None means that the value does not have to exist or is removed.

Note: The operation is guaranteed to be atomic.

val remove : t -> key -> unit Lwt.t

remove t k remove the key k in t.

val list : t -> key -> key list Lwt.t

list t k list the sub-paths of the path k in t.

val remove_rec : t -> key -> unit Lwt.t

Same as RW.remove but removes all the sub-paths recursively.

val empty : unit -> t Lwt.t

Create an empty view. Empty views do not have associated backend configuration values, as they can perform in-memory operation, independently of any given backend.

val rebase : t -> into:t -> unit Merge.result Lwt.t

rebase x t i rebases the actions done on the view t x into the view i x. If a read operation doesn't return the same result, return Conflict. Only the view i is updated.

val rebase_exn : t -> into:t -> unit Lwt.t

Same as rebase but raise Merge.Conflict in case of conflict.

val of_path : db -> key -> t Lwt.t

of_path t p reads the view from a path p in the branch t. This is a cheap operation, all the real reads operation will be done on-demand when the view is used. If p does not exist in t, the the result is an empty view.

val update_path : db -> key -> t -> unit Lwt.t

update_path t p v replaces the sub-tree under p in the branch t by the contents of the view v. See merge_path for more details.

val rebase_path : db -> key -> t -> unit Merge.result Lwt.t

rebase_path t p v rebases the view v on top of the contents of the sub-tree under p in the branch t. Rebasing means re-applying every action stored in v, including the reads. Return Merge.Conflict if one of the actions cannot apply cleanly. See merge_path for more details.

val rebase_path_exn : db -> key -> t -> unit Lwt.t

Same as rebase_path but raise Merge.Conflict in case of conflict.

val merge_path : db -> ?max_depth:int -> ?n:int -> key -> t -> unit Merge.result Lwt.t

merge_path t path v merges the view v with the contents of the sub-tree under p in the branch t. Merging means applying the merge function for map between the view's contents and t's sub-tree.

  • VIEW.update_path discards any pre-existing subtree.
  • VIEW.rebase_path is operation based. It keeps track of read operations which can lead to conflicts. It replays the full operation history of the view on top of any pre-existing subtree.
  • VIEW.merge_path is state based. It is an efficient 3-way merge operator between prefix trees, based on Merge.Map.merge.
val merge_path_exn : db -> ?max_depth:int -> ?n:int -> key -> t -> unit Lwt.t

Same as merge_path but raises Merge.Conflict in case of conflicts.

module Action : sig ... end

Action provides information about operations performed on a view.

val actions : t -> Action.t list

Return the list of actions performed on this view since its creation.

val diff : t -> t -> (key * value diff) list Lwt.t

Compute the diff between two views.

Heads

type commit_id = S.commit_id

The type for commit heads.

val parents : t -> commit_id list

parents t are t's parent commits.

val make_head : db -> task -> parents:commit_id list -> contents:t -> commit_id Lwt.t

make_head t task ~parents ~contents creates a new commit into the store where the branch t is stored and return its id (of type commit_id). The new commit has task as task and the given parents and contents. The actual parents of contents are not used.

val watch_path : db -> key -> ?init:(commit_id * t) -> ((commit_id * t) diff -> unit Lwt.t) -> (unit -> unit Lwt.t) Lwt.t

watch_head t p f calls f every time a subpath of p is updated in the branch t. The callback parameters contain the branch's current head and the corresponding view.

OCaml

Innovation. Community. Security.