summaryrefslogtreecommitdiff
path: root/redis/commands
diff options
context:
space:
mode:
Diffstat (limited to 'redis/commands')
-rw-r--r--redis/commands/cluster.py2
-rw-r--r--redis/commands/json/__init__.py30
-rw-r--r--redis/commands/parser.py9
-rw-r--r--redis/commands/timeseries/__init__.py31
4 files changed, 58 insertions, 14 deletions
diff --git a/redis/commands/cluster.py b/redis/commands/cluster.py
index 8bdcbba..7342c0c 100644
--- a/redis/commands/cluster.py
+++ b/redis/commands/cluster.py
@@ -9,6 +9,7 @@ from .core import (
ScriptCommands,
)
from .helpers import list_or_args
+from .redismodules import RedisModuleCommands
class ClusterMultiKeyCommands:
@@ -212,6 +213,7 @@ class RedisClusterCommands(
PubSubCommands,
ClusterDataAccessCommands,
ScriptCommands,
+ RedisModuleCommands,
):
"""
A class for all Redis Cluster commands
diff --git a/redis/commands/json/__init__.py b/redis/commands/json/__init__.py
index 12c0648..638e4eb 100644
--- a/redis/commands/json/__init__.py
+++ b/redis/commands/json/__init__.py
@@ -103,16 +103,34 @@ class JSON(JSONCommands):
pipe.jsonget('foo')
pipe.jsonget('notakey')
"""
- p = Pipeline(
- connection_pool=self.client.connection_pool,
- response_callbacks=self.MODULE_CALLBACKS,
- transaction=transaction,
- shard_hint=shard_hint,
- )
+ if isinstance(self.client, redis.RedisCluster):
+ p = ClusterPipeline(
+ nodes_manager=self.client.nodes_manager,
+ commands_parser=self.client.commands_parser,
+ startup_nodes=self.client.nodes_manager.startup_nodes,
+ result_callbacks=self.client.result_callbacks,
+ cluster_response_callbacks=self.client.cluster_response_callbacks,
+ cluster_error_retry_attempts=self.client.cluster_error_retry_attempts,
+ read_from_replicas=self.client.read_from_replicas,
+ reinitialize_steps=self.client.reinitialize_steps,
+ )
+
+ else:
+ p = Pipeline(
+ connection_pool=self.client.connection_pool,
+ response_callbacks=self.MODULE_CALLBACKS,
+ transaction=transaction,
+ shard_hint=shard_hint,
+ )
+
p._encode = self._encode
p._decode = self._decode
return p
+class ClusterPipeline(JSONCommands, redis.cluster.ClusterPipeline):
+ """Cluster pipeline for the module."""
+
+
class Pipeline(JSONCommands, redis.client.Pipeline):
"""Pipeline for the module."""
diff --git a/redis/commands/parser.py b/redis/commands/parser.py
index 2bb0576..89292ab 100644
--- a/redis/commands/parser.py
+++ b/redis/commands/parser.py
@@ -17,7 +17,14 @@ class CommandsParser:
self.initialize(redis_connection)
def initialize(self, r):
- self.commands = r.execute_command("COMMAND")
+ commands = r.execute_command("COMMAND")
+ uppercase_commands = []
+ for cmd in commands:
+ if any(x.isupper() for x in cmd):
+ uppercase_commands.append(cmd)
+ for cmd in uppercase_commands:
+ commands[cmd.lower()] = commands.pop(cmd)
+ self.commands = commands
# As soon as this PR is merged into Redis, we should reimplement
# our logic to use COMMAND INFO changes to determine the key positions
diff --git a/redis/commands/timeseries/__init__.py b/redis/commands/timeseries/__init__.py
index 5b1f151..4720a43 100644
--- a/redis/commands/timeseries/__init__.py
+++ b/redis/commands/timeseries/__init__.py
@@ -1,4 +1,4 @@
-import redis.client
+import redis
from ..helpers import parse_to_list
from .commands import (
@@ -67,14 +67,31 @@ class TimeSeries(TimeSeriesCommands):
pipeline.execute()
"""
- p = Pipeline(
- connection_pool=self.client.connection_pool,
- response_callbacks=self.MODULE_CALLBACKS,
- transaction=transaction,
- shard_hint=shard_hint,
- )
+ if isinstance(self.client, redis.RedisCluster):
+ p = ClusterPipeline(
+ nodes_manager=self.client.nodes_manager,
+ commands_parser=self.client.commands_parser,
+ startup_nodes=self.client.nodes_manager.startup_nodes,
+ result_callbacks=self.client.result_callbacks,
+ cluster_response_callbacks=self.client.cluster_response_callbacks,
+ cluster_error_retry_attempts=self.client.cluster_error_retry_attempts,
+ read_from_replicas=self.client.read_from_replicas,
+ reinitialize_steps=self.client.reinitialize_steps,
+ )
+
+ else:
+ p = Pipeline(
+ connection_pool=self.client.connection_pool,
+ response_callbacks=self.MODULE_CALLBACKS,
+ transaction=transaction,
+ shard_hint=shard_hint,
+ )
return p
+class ClusterPipeline(TimeSeriesCommands, redis.cluster.ClusterPipeline):
+ """Cluster pipeline for the module."""
+
+
class Pipeline(TimeSeriesCommands, redis.client.Pipeline):
"""Pipeline for the module."""