LWWRegister

class LWWRegister : DeltaCRDT

A delta-based CRDT Last Writer Wins (LWW) register.

Only the last written value is retained: the previous value (if any) is discarded.

When merging, only the value associated with the greatest timestamp is retained. A deletion is represented as a null value and handled the same way.

Its JSON serialization respects the following schema:

{
"type": "LWWRegister",
"metadata": Timestamp.toJson(),
"value": $value
}

Constructors

LWWRegister
Link copied to clipboard
common
fun LWWRegister()
Constructs an empty LWWRegister instance.
LWWRegister
Link copied to clipboard
common
fun LWWRegister(env: Environment)
LWWRegister
Link copied to clipboard
common
fun LWWRegister(value: String, env: Environment)
Constructs a LWWRegister instance initialized with a given value and environment.
LWWRegister
Link copied to clipboard
common
fun LWWRegister(other: LWWRegister)
Copy constructor, discarding associated environment

Types

Companion
Link copied to clipboard
common
object Companion

Functions

assign
Link copied to clipboard
common
fun assign(v: String): LWWRegister
Assigns a given value to the register.
equals
Link copied to clipboard
common
open operator fun equals(other: Any?): Boolean
generateDelta
Link copied to clipboard
common
open override fun generateDelta(vv: VersionVector): LWWRegister
Return a delta from a given version vector vv to current state.
get
Link copied to clipboard
common
fun get(): String?
Gets the value currently stored in the register.
hashCode
Link copied to clipboard
common
open fun hashCode(): Int
merge
Link copied to clipboard
common
open override fun merge(delta: DeltaCRDT)
Merge a given delta into this DeltaCRDTThe merge is unidirectional: only the local replica is modified.
toJson
Link copied to clipboard
common
open override fun toJson(): String
Serialize this DeltaCRDT to a JSON string.
toString
Link copied to clipboard
common
open fun toString(): String

Properties

ts
Link copied to clipboard
common
var ts: Timestamp? = null
The timestamp associated to the value.
value
Link copied to clipboard
common
var value: String? = null
The string value stored in the register.