Hi guys,

I am using Lua script to execute the logic as a transaction. But Lua script can fail in the middle and do not support the rollback. The failure may be caused by the wrong data type, syntax, or Redis cash,...

The logic touches many keys and must ensure that data in each key is consistent. For example, the total balance in all keys never changes.

This requires Atomicity in ACID (all or nothing). I plan to migrate all keys to a hash and using hset multiple field/value pairs to update field values.

I know that hset is Atomicity, but does it All or Nothing? There is any change that hset field1 value1 field2 value2 could set field1 only?

Thanks.

Comment From: sundb

hset field1 value1 field2 value2 is also atomic.

Comment From: VoxT

So, it's All or Nothing, isn't it? @sundb

Comment From: sundb

Yes, Indeed.

Comment From: VoxT

I get it, thank you @sundb

Comment From: anhldbk

@antirez @itamarhaber I'm considering to update Redis Doc about hset about this atomic guarantee. Is there any further internals that I can link to?

Comment From: sundb

I think I'm missing something, hset is atomic in standalone mode, but not in cluster mode.

Comment From: itamarhaber

@anhldbk I don't understand the need to update the docs. All multi-key operations in Redis are atomic (pretty sure that's mentions somewhere), and even more so variadic ones. Repeating that for each command explicitly feels superfluous to me.

@sundb hset is atomic in cluster mode - it is a single key command so nothing to worry about.

Comment From: josh-endries

FWIW, I just arrived here because, after looking at the doc for HSET, I wanted to know if it was atomic for multiple KVPs. I think it's worth documenting it, or linking to something that documents it. People don't always arrive at a thing through a certain path.