Counters
Id generator¶
Java implementation of Valkey or Redis based Id generator RIdGenerator generates unique numbers but not monotonically increased. At first request, batch of id numbers is allocated and cached on Java side till it's exhausted. This approach allows to generate ids faster than RAtomicLong.
Default allocation size is 5000. Default start value is 0.
Code examples:
AtomicLong¶
Java implementation of Valkey or Redis based AtomicLong object provides API similar to java.util.concurrent.atomic.AtomicLong object.
Code examples:
AtomicDouble¶
Java implementation of Valkey or Redis based AtomicDouble object.
Code examples:
LongAdder¶
Java implementation of Valkey or Redis based LongAdder object provides API similar to java.util.concurrent.atomic.LongAdder object.
It maintains internal LongAdder object on client side and provides superior performance for both increment and decrement operations. Up to 12000x faster than similar AtomicLong
object. Suitable for distributed metric objects.
Code example:
RLongAdder atomicLong = redisson.getLongAdder("myLongAdder");
atomicLong.add(12);
atomicLong.increment();
atomicLong.decrement();
atomicLong.sum();
Object should be destroyed if it's not used anymore, but it's not necessary to call destroy method if Redisson goes shutdown.
DoubleAdder¶
Java implementation of Valkey or Redis based DoubleAdder object provides API similar to java.util.concurrent.atomic.DoubleAdder object.
It maintains internal DoubleAdder object on client side and provides superior performance for both increment and decrement operations. Up to 12000x faster than similar AtomicDouble
object. Suitable for distributed metric objects.
Code example:
RLongDouble atomicDouble = redisson.getLongDouble("myLongDouble");
atomicDouble.add(12);
atomicDouble.increment();
atomicDouble.decrement();
atomicDouble.sum();
Object should be destroyed if it's not used anymore, but it's not necessary to call destroy method if Redisson goes shutdown.