I do use Redis transactions (multi/exec) to achieve it. I guess Lua code would be similar. But the problem with this approach is that - if a lot of these operations are done in parallel, it causes most of them to fail, because of optimistic locking. And then, one needs to retry the failed ones. It would much better if REDIS provided this function inherently (similar to SETNX), in which case it would be much faster.
My use case is that I want to make sure that update only happens for newer entries, thus I compare timestamps and only update if the timestamp is greater. I guess that would be a pretty common use case and would benefit many.