Package redis :: Module client :: Class BasePipeline
[frames] | no frames]

Class BasePipeline

source code

object --+
         |
        BasePipeline
Known Subclasses:

Pipelines provide a way to transmit multiple commands to the Redis server in one transmission. This is convenient for batch processing, such as saving all the values in a list to Redis.

All commands executed within a pipeline are wrapped with MULTI and EXEC calls. This guarantees all commands executed in the pipeline will be executed atomically.

Any command raising an exception does *not* halt the execution of subsequent commands in the pipeline. Instead, the exception is caught and its instance is placed into the response list returned by execute(). Code iterating over the response list should be able to deal with an instance of an exception as a potential value. In general, these will be ResponseError exceptions, such as those raised when issuing a command on a key of a different datatype.

Instance Methods
 
__init__(self, connection_pool, response_callbacks, transaction, shard_hint)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__enter__(self) source code
 
__exit__(self, exc_type, exc_value, traceback) source code
 
__del__(self) source code
 
reset(self) source code
 
multi(self)
Start a transactional block of the pipeline after WATCH commands are issued.
source code
 
execute_command(self, *args, **kwargs) source code
 
immediate_execute_command(self, *args, **options)
Execute a command immediately, but don't auto-retry on a ConnectionError if we're already WATCHing a variable.
source code
 
pipeline_execute_command(self, *args, **options)
Stage a command to be executed when execute() is next called
source code
 
parse_response(self, connection, command_name, **options) source code
 
load_scripts(self) source code
 
execute(self)
Execute all the commands in the current pipeline
source code
 
watch(self, *names)
Watches the values at keys ``names``
source code
 
unwatch(self)
Unwatches all previously specified keys
source code
 
script_load_for_pipeline(self, script)
Make sure scripts are loaded prior to pipeline execution
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables
  UNWATCH_COMMANDS = set(['DISCARD', 'EXEC', 'UNWATCH'])
Properties

Inherited from object: __class__

Method Details

__init__(self, connection_pool, response_callbacks, transaction, shard_hint)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

multi(self)

source code 

Start a transactional block of the pipeline after WATCH commands are issued. End the transactional block with `execute`.

immediate_execute_command(self, *args, **options)

source code 

Execute a command immediately, but don't auto-retry on a ConnectionError if we're already WATCHing a variable. Used when issuing WATCH or subsequent commands retrieving their values but before MULTI is called.

pipeline_execute_command(self, *args, **options)

source code 

Stage a command to be executed when execute() is next called

Returns the current Pipeline object back so commands can be chained together, such as:

pipe = pipe.set('foo', 'bar').incr('baz').decr('bang')

At some other point, you can then run: pipe.execute(), which will execute all commands queued in the pipe.