[Feature Request] Allow DEL of non existing key to impact transaction state

18 views
Skip to first unread message

Andrew Shvayka

unread,
May 7, 2022, 10:12:12 AMMay 7
to Redis DB
Greetings,

I am trying to improve the "Cache Aside" policy of our application. The idea is to use "WATCH" and "MULTI/EXEC" commands. But I face that the "DEL" command on the non-existing key does not cancel the transaction. It is clear that the DEL command works according to the documentation. However, I will try to prove that it may be useful to support the following scenario:

The "Read" operation:
t1. GET key // cache miss.
t2. WATCH key // start monitoring the key for concurrent updates.
t5. fetch "OLD_VALUE" from the DB.
t6. MULTI
t7. SETNX key OLD_VALUE
t8. EXEC

Meanwhile, The "Save" operation is updating the value in DB and clears the cache after we executed WATCH (t2) and before we executed EXEC (t8):
t3. save "NEW_VALUE" to the DB
t4. DEL key.

So, in this case, it would be very useful if the DEL command could affect the behavior of the transaction and make it fail. Let's discuss? What is the proper way to submit feature request?

Thank you!

sundb

unread,
May 9, 2022, 3:51:33 AMMay 9
to Redis DB
Not sure if I understand you correctly.
Is this the following case?

Client 1:
t1. GET key // cache miss.
t2. WATCH key // start monitoring the key for concurrent updates.
t5. GET key
t6. MULTI
t7. SETNX key OLD_VALUE
t8. EXEC

client 2:
t3. SET key NEW_VALUE
t4. DEL key.

Reply all
Reply to author
Forward
0 new messages