diff options
author | Chayim <chayim@users.noreply.github.com> | 2021-11-09 11:24:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-09 11:24:48 +0200 |
commit | 599f5a991eda770799a1aea23848b1442019deeb (patch) | |
tree | 58dedbde03bb1671dbdf0100159e25353b466ef3 /redis/commands/json/__init__.py | |
parent | fea7b85dde375a228f485d27737de66592b28848 (diff) | |
download | redis-py-599f5a991eda770799a1aea23848b1442019deeb.tar.gz |
Re-enable pipeline support for JSON and TimeSeries (#1674)
Diffstat (limited to 'redis/commands/json/__init__.py')
-rw-r--r-- | redis/commands/json/__init__.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/redis/commands/json/__init__.py b/redis/commands/json/__init__.py index d00627e..d634dbd 100644 --- a/redis/commands/json/__init__.py +++ b/redis/commands/json/__init__.py @@ -6,6 +6,7 @@ from .decoders import ( ) from ..helpers import nativestr from .commands import JSONCommands +import redis class JSON(JSONCommands): @@ -91,3 +92,29 @@ class JSON(JSONCommands): def _encode(self, obj): """Get the encoder.""" return self.__encoder__.encode(obj) + + def pipeline(self, transaction=True, shard_hint=None): + """Creates a pipeline for the JSON module, that can be used for executing + JSON commands, as well as classic core commands. + + Usage example: + + r = redis.Redis() + pipe = r.json().pipeline() + pipe.jsonset('foo', '.', {'hello!': 'world'}) + 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, + ) + p._encode = self._encode + p._decode = self._decode + return p + + +class Pipeline(JSONCommands, redis.client.Pipeline): + """Pipeline for the module.""" |