Documentation - Redise Pack

A guide to Redise Pack installation, operation and administration

open all | close all

Developing with Sets in a CRDB

Note: This page only pertains to Redis Enterprise Pack v5.0 Preview.

Redis Sets are an unordered collection of Strings. It is possible to add, remove, and test for the existence of members with Redis commands. A Redis set maintains a unique collection of elements. Sets can be great for maintaining a list of events (click streams), users (in a group conversation), products (in recommendation lists), engagements (likes, shares) and so on.

Sets in CRDBs behave the same and maintain additional metadata to achieve an “OR-Set” behavior to handle concurrent conflicting writes. With the OR-Set behavior, writes across multiple member CRDBs are typically unioned except in cases of conflicts. Conflicting member writes can happen when an mCRDB deletes an element while the other adds the same element. In this case and observed remove rule is followed. That is, remove can only remove members it has already seen and in all other cases element add wins.

Here is an example of an “add wins” case:

Time Member CRDB1 Member CRDB2
t1 SADD key1 “a”
t2 SADD key1 “b”
t3 SMEMBERS key1
“a”
SMEMBERS key1
“b”
t4 — Sync —
t3 SMEMBERS key1
“a”
“b”
SMEMBERS key1
“a”
“b”

Here is an example of an “observed remove” case.

Time Member CRDB1 Member CRDB2
t1 SMEMBERS key1
“a”
“b”
SMEMBERS key1
“a”
“b”
t2 SREM key1 “a” SADD key1 “c”
t3 SREM key1 “c”
t4 — Sync —
t3 SMEMBERS key1
“c”
“b”
SMEMBERS key1
“c”
“b”