1- from redis .client import bool_ok
1+ import redis .client
22
33from .utils import (
44 parse_range ,
@@ -37,12 +37,12 @@ class TimeSeries(TimeSeriesCommands):
3737 def __init__ (self , client = None , version = None , ** kwargs ):
3838 """Create a new RedisTimeSeries client."""
3939 # Set the module commands' callbacks
40- MODULE_CALLBACKS = {
41- CREATE_CMD : bool_ok ,
42- ALTER_CMD : bool_ok ,
43- CREATERULE_CMD : bool_ok ,
40+ self . MODULE_CALLBACKS = {
41+ CREATE_CMD : redis . client . bool_ok ,
42+ ALTER_CMD : redis . client . bool_ok ,
43+ CREATERULE_CMD : redis . client . bool_ok ,
4444 DEL_CMD : int ,
45- DELETERULE_CMD : bool_ok ,
45+ DELETERULE_CMD : redis . client . bool_ok ,
4646 RANGE_CMD : parse_range ,
4747 REVRANGE_CMD : parse_range ,
4848 MRANGE_CMD : parse_m_range ,
@@ -57,5 +57,30 @@ def __init__(self, client=None, version=None, **kwargs):
5757 self .execute_command = client .execute_command
5858 self .MODULE_VERSION = version
5959
60- for k in MODULE_CALLBACKS :
61- self .client .set_response_callback (k , MODULE_CALLBACKS [k ])
60+ for key , value in self .MODULE_CALLBACKS .items ():
61+ self .client .set_response_callback (key , value )
62+
63+ def pipeline (self , transaction = True , shard_hint = None ):
64+ """Creates a pipeline for the TimeSeries module, that can be used
65+ for executing only TimeSeries commands and core commands.
66+
67+ Usage example:
68+
69+ r = redis.Redis()
70+ pipe = r.ts().pipeline()
71+ for i in range(100):
72+ pipeline.add("with_pipeline", i, 1.1 * i)
73+ pipeline.execute()
74+
75+ """
76+ p = Pipeline (
77+ connection_pool = self .client .connection_pool ,
78+ response_callbacks = self .MODULE_CALLBACKS ,
79+ transaction = transaction ,
80+ shard_hint = shard_hint ,
81+ )
82+ return p
83+
84+
85+ class Pipeline (TimeSeriesCommands , redis .client .Pipeline ):
86+ """Pipeline for the module."""
0 commit comments