summaryrefslogtreecommitdiff
path: root/redis/utils.py
diff options
context:
space:
mode:
authorBar Shaul <88437685+barshaul@users.noreply.github.com>2021-11-25 14:15:24 +0200
committerGitHub <noreply@github.com>2021-11-25 14:15:24 +0200
commit9db1eec71b443b8e7e74ff503bae651dc6edf411 (patch)
treece23ac6f923df54676349603f4e5551dfc801057 /redis/utils.py
parent021d4ac0edaecedb9b83235700cc4699cb119ef1 (diff)
downloadredis-py-9db1eec71b443b8e7e74ff503bae651dc6edf411.tar.gz
Adding RedisCluster client to support Redis Cluster Mode (#1660)
Co-authored-by: Chayim <chayim@users.noreply.github.com> Co-authored-by: Anas <anas.el.amraoui@live.com>
Diffstat (limited to 'redis/utils.py')
-rw-r--r--redis/utils.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/redis/utils.py b/redis/utils.py
index 26fb002..0e78cc5 100644
--- a/redis/utils.py
+++ b/redis/utils.py
@@ -36,3 +36,39 @@ def str_if_bytes(value):
def safe_str(value):
return str(str_if_bytes(value))
+
+
+def dict_merge(*dicts):
+ """
+ Merge all provided dicts into 1 dict.
+ *dicts : `dict`
+ dictionaries to merge
+ """
+ merged = {}
+
+ for d in dicts:
+ merged.update(d)
+
+ return merged
+
+
+def list_keys_to_dict(key_list, callback):
+ return dict.fromkeys(key_list, callback)
+
+
+def merge_result(command, res):
+ """
+ Merge all items in `res` into a list.
+
+ This command is used when sending a command to multiple nodes
+ and they result from each node should be merged into a single list.
+
+ res : 'dict'
+ """
+ result = set()
+
+ for v in res.values():
+ for value in v:
+ result.add(value)
+
+ return list(result)