org.redisson.api.RAtomicDouble Java Examples
The following examples show how to use
org.redisson.api.RAtomicDouble.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AtomicDoubleExamples.java From redisson-examples with Apache License 2.0 | 6 votes |
public static void main(String[] args) { // connects to 127.0.0.1:6379 by default RedissonClient redisson = Redisson.create(); RAtomicDouble atomicDouble = redisson.getAtomicDouble("myDouble"); atomicDouble.getAndDecrement(); atomicDouble.getAndIncrement(); atomicDouble.addAndGet(10.323); atomicDouble.compareAndSet(29.4, 412.91); atomicDouble.decrementAndGet(); atomicDouble.incrementAndGet(); atomicDouble.getAndAdd(302.00); atomicDouble.getAndDecrement(); atomicDouble.getAndIncrement(); redisson.shutdown(); }
Example #2
Source File: RedissonAtomicDoubleTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void test() { RAtomicDouble al = redisson.getAtomicDouble("test"); assertThat(al.get()).isEqualTo(0); assertThat(al.getAndIncrement()).isEqualTo(0); assertThat(al.get()).isEqualTo(1); assertThat(al.getAndDecrement()).isEqualTo(1); assertThat(al.get()).isEqualTo(0); assertThat(al.getAndIncrement()).isEqualTo(0); assertThat(al.getAndSet(12.8012)).isEqualTo(1); assertThat(al.get()).isEqualTo(12.8012); al.set(1.00123); double state = redisson.getAtomicDouble("test").get(); assertThat(state).isEqualTo(1.00123); al.set(BigDecimal.valueOf(Long.MAX_VALUE).doubleValue()); al.incrementAndGet(); double newState = redisson.getAtomicDouble("test").get(); assertThat(newState).isEqualTo(BigDecimal.valueOf(Long.MAX_VALUE).doubleValue()); }
Example #3
Source File: RedissonAtomicDoubleTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testGetAndDelete() { RAtomicDouble al = redisson.getAtomicDouble("test"); al.set(10.34); assertThat(al.getAndDelete()).isEqualTo(10.34); assertThat(al.isExists()).isFalse(); RAtomicDouble ad2 = redisson.getAtomicDouble("test2"); assertThat(ad2.getAndDelete()).isZero(); }
Example #4
Source File: RedissonAtomicDoubleTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testCompareAndSet() { RAtomicDouble al = redisson.getAtomicDouble("test"); assertThat(al.compareAndSet(-1, 2.5)).isFalse(); assertThat(al.get()).isZero(); assertThat(al.compareAndSet(0, 2.5)).isTrue(); assertThat(al.get()).isEqualTo(2.5); }
Example #5
Source File: RedissonAtomicDoubleTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testSetThenIncrement() { RAtomicDouble al = redisson.getAtomicDouble("test"); al.set(2.81); assertThat(al.getAndIncrement()).isEqualTo(2.81); assertThat(al.get()).isEqualTo(3.81); }
Example #6
Source File: RedissonAtomicDoubleTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testDecrementAndGet() { RAtomicDouble al = redisson.getAtomicDouble("test"); al.set(19.30); assertThat(al.decrementAndGet()).isEqualTo(18.30); assertThat(al.get()).isEqualTo(18.30); }
Example #7
Source File: TracingRAtomicDouble.java From java-redis-client with Apache License 2.0 | 4 votes |
public TracingRAtomicDouble(RAtomicDouble atomicDouble, TracingRedissonHelper tracingRedissonHelper) { super(atomicDouble, tracingRedissonHelper); this.atomicDouble = atomicDouble; this.tracingRedissonHelper = tracingRedissonHelper; }
Example #8
Source File: TracingRedissonClient.java From java-redis-client with Apache License 2.0 | 4 votes |
@Override public RAtomicDouble getAtomicDouble(String name) { return new TracingRAtomicDouble(redissonClient.getAtomicDouble(name), tracingRedissonHelper); }
Example #9
Source File: RedissonAtomicDoubleTest.java From redisson with Apache License 2.0 | 4 votes |
@Test public void testGetAndSet() { RAtomicDouble al = redisson.getAtomicDouble("test"); assertThat(al.getAndSet(12)).isEqualTo(0); }
Example #10
Source File: RedissonAtomicDoubleTest.java From redisson with Apache License 2.0 | 4 votes |
@Test public void testGetZero() { RAtomicDouble ad2 = redisson.getAtomicDouble("test"); assertThat(ad2.get()).isZero(); }
Example #11
Source File: RedissonAtomicDoubleTest.java From redisson with Apache License 2.0 | 4 votes |
@Test public void testIncrementAndGet() { RAtomicDouble al = redisson.getAtomicDouble("test"); assertThat(al.incrementAndGet()).isEqualTo(1); assertThat(al.get()).isEqualTo(1); }
Example #12
Source File: RedissonAtomicDoubleTest.java From redisson with Apache License 2.0 | 4 votes |
@Test public void testGetAndIncrement() { RAtomicDouble al = redisson.getAtomicDouble("test"); assertThat(al.getAndIncrement()).isEqualTo(0); assertThat(al.get()).isEqualTo(1); }