diff options
author | Bar Shaul <88437685+barshaul@users.noreply.github.com> | 2021-11-25 14:15:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-25 14:15:24 +0200 |
commit | 9db1eec71b443b8e7e74ff503bae651dc6edf411 (patch) | |
tree | ce23ac6f923df54676349603f4e5551dfc801057 /redis/utils.py | |
parent | 021d4ac0edaecedb9b83235700cc4699cb119ef1 (diff) | |
download | redis-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.py | 36 |
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) |