user1846749
user1846749

Reputation: 2535

Redisson client setnx

I am using Redisson as java redis library whats the corresponding function in redisson for setnx(conditional set a key's value and get result as 1 if value is set). I am using redis in clustered mode (sharded cluster).

Thanks

Upvotes: 5

Views: 1815

Answers (1)

Nikita Koksharov
Nikita Koksharov

Reputation: 10783

Use RBucket object:

RBucket<Object> bucket = redisson.getBucket("myObject");
bucket.trySet(object); // return true if object wasn't set before

Also you can refer to https://github.com/redisson/redisson/wiki/11.-Redis-commands-mapping for mapping of other Redis commands.

Upvotes: 6

Related Questions