237
237
.. code :: python
238
238
239
239
>> > with r.pipeline(transaction = True ) as pipe: # Using context manager
240
- >> > pipe.set(" key" , " value" )
241
- >> > pipe.get(" key" )
242
- >> > response = pipe.execute()
240
+ ... pipe.set(" key" , " value" )
241
+ ... pipe.get(" key" )
242
+ ... response = pipe.execute()
243
243
244
244
As you see there's no need to explicitly send `MULTI/EXEC ` commands to control context start/end
245
245
`ClusterPipeline ` will take care of it.
@@ -252,11 +252,11 @@ More information `here <https://redis.io/docs/latest/operate/oss_and_stack/refer
252
252
.. code :: python
253
253
254
254
>> > with r.pipeline(transaction = True ) as pipe:
255
- >> > pipe.set(" {tag} foo" , " bar" )
256
- >> > pipe.set(" {tag} bar" , " foo" )
257
- >> > pipe.get(" {tag} foo" )
258
- >> > pipe.get(" {tag} bar" )
259
- >> > response = pipe.execute()
255
+ ... pipe.set(" {tag} foo" , " bar" )
256
+ ... pipe.set(" {tag} bar" , " foo" )
257
+ ... pipe.get(" {tag} foo" )
258
+ ... pipe.get(" {tag} bar" )
259
+ ... response = pipe.execute()
260
260
261
261
CAS Transactions
262
262
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -274,12 +274,12 @@ transaction execution.
274
274
.. code :: python
275
275
276
276
>> > with r.pipeline(transaction = True ) as pipe:
277
- >> > pipe.watch(" mykey" ) # Apply locking by immediately executing command
278
- >> > val = pipe.get(" mykey" ) # Immediately retrieves value
279
- >> > val = val + 1 # Increment value
280
- >> > pipe.multi() # Starting transaction context
281
- >> > pipe.set(" mykey" , val) # Command will be pipelined
282
- >> > response = pipe.execute() # Returns OK or None if key was modified in the meantime
277
+ ... pipe.watch(" mykey" ) # Apply locking by immediately executing command
278
+ ... val = pipe.get(" mykey" ) # Immediately retrieves value
279
+ ... val = val + 1 # Increment value
280
+ ... pipe.multi() # Starting transaction context
281
+ ... pipe.set(" mykey" , val) # Command will be pipelined
282
+ ... response = pipe.execute() # Returns OK or None if key was modified in the meantime
283
283
284
284
285
285
Publish / Subscribe
0 commit comments