Hi, I'm using watch for the first time. My goal is to implement
something like check-and-set (CAS) behavior (http://redis.io/topics/
transactions)
So I've got code (its Scala, not Java) like this:
jedis.watch(key)
val value: String = jedis.get(key)
// do calculations
val newValue: String = calculate(value)
val t: Transaction = jedis.multi
t.set(key, newValue)
t.exec
So, how what I want to have happen is to fail/abort the transaction if
key was modified in between my get and set.
1. Is this correct?
2. How do I detect the failure scenario? Maybe t.exec returns null
when the transaction is aborted?
thanks
- Alex