Skip to content

Commit 71fb322

Browse files
DOC-4560 removed content overlapping with explanatory page, per feedback
1 parent 5eef5b8 commit 71fb322

File tree

1 file changed

+6
-27
lines changed

1 file changed

+6
-27
lines changed

content/develop/clients/redis-py/transpipe.md

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ There are two types of batch that you can use:
2020

2121
- **Pipelines** avoid network and processing overhead by sending several commands
2222
to the server together in a single communication. The server then sends back
23-
a single communication with all the responses. This typically improves
24-
performance compared to sending the commands separately. See the
23+
a single communication with all the responses. See the
2524
[Pipelining]({{< relref "/develop/use/pipelining" >}}) page for more
2625
information.
2726
- **Transactions** guarantee that all the included commands will execute
@@ -80,31 +79,11 @@ pipe = r.pipeline(transaction=False)
8079

8180
## Watch keys for changes
8281

83-
When you use transactions, you will often need to read values from the
84-
database, process them, and then write the modified values back. Ideally,
85-
you would want to perform the whole read-modify-write sequence atomically, without any
86-
interruptions from other clients. However, you don't get the results from
87-
any commands that are buffered in a transaction until the whole transaction has finished
88-
executing. This means you can't read keys, process the data, and then write the keys back
89-
in the same transaction. Other clients can therefore modify the values you have
90-
read before you have the chance to write them.
91-
92-
Redis solves this problem by letting you watch for changes to keys in the
93-
database just before executing a transaction. The basic stages are as
94-
follows:
95-
96-
1. Start watching the keys you are about to update.
97-
1. Read the data values from those keys.
98-
1. Perform changes to the data values.
99-
1. Add commands to a transaction to write the data values back.
100-
1. Attempt to execute the transaction.
101-
1. If the keys you were watching changed before the transaction started
102-
executing, then abort the transaction and start again from step 1.
103-
Otherwise, the transaction was successful and the updated data is written back.
104-
105-
This technique is called *optimistic locking* and works well in cases
106-
where multiple clients might access the same data simultaneously, but
107-
usually don't. See
82+
Redis supports *optimistic locking* to avoid inconsistent updates
83+
to different keys. The basic idea is to watch for changes to any
84+
keys that you use in a transaction while you are are processing the
85+
updates. If the watched keys do change, you must restart the updates
86+
with the latest data from the keys. See
10887
[Transactions]({{< relref "/develop/interact/transactions" >}})
10988
for more information about optimistic locking.
11089

0 commit comments

Comments
 (0)