public static void main(String[] args) { RedissonClient redisson = Redisson.create(); RBucket<String> bucket = redisson.getBucket("test"); bucket.set("123"); boolean isUpdated = bucket.compareAndSet("123", "4934"); String prevObject = bucket.getAndSet("321"); boolean isSet = bucket.trySet("901"); long objectSize = bucket.size(); // set with expiration bucket.set("value", 10, TimeUnit.SECONDS); boolean isNewSet = bucket.trySet("nextValue", 10, TimeUnit.SECONDS); redisson.shutdown(); }
public static void main(String[] args) { // connects to 127.0.0.1:6379 by default RedissonClient redisson = Redisson.create(); RBucket<String> bucket = redisson.getBucket("test"); bucket.set("123"); boolean isUpdated = bucket.compareAndSet("123", "4934"); String prevObject = bucket.getAndSet("321"); boolean isSet = bucket.trySet("901"); long objectSize = bucket.size(); // set with expiration bucket.set("value", 10, TimeUnit.SECONDS); boolean isNewSet = bucket.trySet("nextValue", 10, TimeUnit.SECONDS); redisson.shutdown(); }