CRDT v0.2.0 CRDT.LWWRegister View Source
A last-write wins register
Link to this section Summary
Functions
Incorporate a remote LWWRegister
Initialize a new LWWRegister
Set the value of the LWWRegister
Link to this section Types
Link to this type
t()
View Source
t() :: %CRDT.LWWRegister{id: id(), ts: ts(), value: value(), vec: vec()}
An LWWRegister with a local vector clock and remote values
Link to this section Functions
Incorporate a remote LWWRegister.
iex> r = LWWRegister.init()
iex> r2 = LWWRegister.init() |> LWWRegister.set(2)
iex> r
...> |> LWWRegister.incorporate(r2.ts, r2.value)
...> |> Map.get(:value)
2
Initialize a new LWWRegister.
Accepts an initial value, which defaults to nil
.
iex> LWWRegister.init() |> Map.get(:value)
nil
iex> LWWRegister.init("test") |> Map.get(:value)
"test"
Set the value of the LWWRegister.
iex> LWWRegister.init(1) |> LWWRegister.set(2) |> Map.get(:value)
2