CRDT Types¶
Data types that are called CRDT which is either Conflict-free Replicated Data Type or Commutative Replicated Data Types are used in lattices.
Available types:
-
counter
¶ ever-increasing counter
// some initial value {"user_visits_counter": 1} // next value {"user_visits_counter": 2} // on update this value will be ignored {"user_visits_counter": 1}
-
set
¶ - set of some elements, the set can only grow (new elements added) and elements can never be deleted from the set
{"last_message_set": [1, 12, 13465]} // on update -- will have no effect {"last_message_set": [1, 12]}
-
register
¶ a value with a timestamp or a version, which is updated with last-write-wins (LWW) semantics. Any valid json might be used as a value.
{"status_register": [1, {"icon": "busy", "message": "working"}]} // next value {"status_register": [2, {"icon": "ready_for_chat", "message": "???"}]} // on update -- will have no effect {"status_register": [1, {"icon": "offline", "message": "disconnected"}]} {"another_register": [1503339804.859186, "hello_string"]}
Note
Only non-negative values might be used as a version. Both integers and floating point number are okay, but value will be treated