0

If I want to set a bucket in Redisson, do I need to prevent race condition by incorporating Redisson.getLock()? Or RBucket.set() does that internally?

In general, other than application requirements, is there any scenario that I need to surround a block by locks before setting / getting something to / from Redisson?

Mehran
  • 15,593
  • 27
  • 122
  • 221

1 Answers1

1

Actually you don't need to use Lock with Bucket object, because all redis/redisson operations are atomic.

Nikita Koksharov
  • 10,283
  • 1
  • 62
  • 71
  • Could you please provide some reference too? – Mehran Dec 20 '16 at 18:20
  • @Mehran https://redis.io/commands/eval `Atomicity of scripts` section. Redisson uses lot of lua scripts. Redis is single-threaded process. Thus, only one command could be executed concurrently. – Nikita Koksharov Dec 20 '16 at 20:07
  • @Mehran here is bucket object usage examples https://github.com/redisson/redisson-examples/blob/master/objects-examples/src/main/java/org/redisson/example/objects/BucketExamples.java – Nikita Koksharov Dec 20 '16 at 20:13