summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorZheng Chao <[email protected]>2022-11-30 10:50:46 +0800
committerZheng Chao <[email protected]>2022-11-30 10:50:46 +0800
commitbf2d2e184f381c8f82a38cbc84b0cbd688413a35 (patch)
tree476a7d8fed5139fc082b3e5df9ba7e377c23d9cc /docs
parente19de4ab3592690e3d0a54447b088ad38aa48683 (diff)
:sparkles: Support `KEYSLOT` command.
Diffstat (limited to 'docs')
-rw-r--r--docs/commands.md18
-rw-r--r--docs/design.md2
2 files changed, 18 insertions, 2 deletions
diff --git a/docs/commands.md b/docs/commands.md
index a89b9c6..45483da 100644
--- a/docs/commands.md
+++ b/docs/commands.md
@@ -80,6 +80,22 @@ Return
- 1 if the timeout was removed.
- 0 if key does not exist or does not have an associated timeout.
+
+### KEYSLOT
+
+Syntax
+
+```
+KEYSLOT key
+```
+
+Returns an integer identifying the hash slot the specified key hashes to. This command is mainly useful for debugging and testing.
+
+Return
+
+- Integer reply: The hash slot number.
+
+
## String and Integer
### GET
@@ -524,6 +540,7 @@ The pattern is exactly same as Redis https://redis.io/commands/keys/ .
| EXPIRE | key seconds | Integer reply, specifically: 1 if the timeout was set. 0 if the timeout was not set. e.g. key doesn't exist |
| TTL | key | Integer reply: TTL in seconds, in case of error: -2 if the key does not exist; -1 if the key exists but has no associated expire. |
| PERSIST | key | Integer reply, specifically:<br/><br/>1 if the timeout was removed.<br/>0 if key does not exist or does not have an associated timeout. |
+| KEYSLOT | key | Integer reply: The hash slot the specified key hashes to. |
| SADD | key member [member ...] | Integer reply: the number of elements that were added to the set, not including all the elements already present in the set. |
| SREM | key member [member ...] | Integer reply: the number of members that were removed from the set, not including non existing members. The key will NOT be deleted if all members are removed. If key does not exist, it is treated as an empty set and this command returns 0. |
| SCARD | key | Integer reply: the cardinality (number of elements) of the set, or 0 if key does not exist. |
@@ -547,7 +564,6 @@ The pattern is exactly same as Redis https://redis.io/commands/keys/ .
| CRDT PUSH | key blob | Simple string reply: OK if PUSH was executed correctly. |
| CRDT PULL | key | Blog reply: a blob of state-based CRDT |
| CLUSTER KEYS | pattern | Array reply: list of keys matching pattern. |
-| CLUSTER KEYSLOT | keyslot | Integer reply: The hash slot the specified key hashes to. |
| CLUSTER NODES | | |
| CLUSTER SLOTS | | |
| CLUSTER ADDNODE | IP:port | |
diff --git a/docs/design.md b/docs/design.md
index 7b1d701..c0b1d1a 100644
--- a/docs/design.md
+++ b/docs/design.md
@@ -78,7 +78,7 @@ Except for node in dry run mode, cluster nodes will watch leadership changes and
### Hash tags
-Like [Redis Cluster](https://redis.io/docs/reference/cluster-spec/), SwarmKV implements hash tags, which can be used to ensure that multiple keys are allocated in the same hash slot. If the key contains a "{...}" pattern only the substring between `{` and `}` is hashed in order to obtain the hash slot. However since it is possible that there are multiple occurrences of `{` or `}` the algorithm is well specified by the following rules:
+Like [Redis Cluster](https://redis.io/docs/reference/cluster-spec/), SwarmKV implements hash tags, which can be used to ensure that multiple keys are allocated in the same hash slot for managed by the same key owner. Note that the hash tags does not guarrantee objects are managed by the same object owner. If the key contains a "{...}" pattern only the substring between `{` and `}` is hashed in order to obtain the hash slot. However since it is possible that there are multiple occurrences of `{` or `}` the algorithm is well specified by the following rules:
- IF the key contains a `{` character.
- AND IF there is a `}` character to the right of `{`.