Package org.redisson

Class RedissonAtomicDouble

java.lang.Object
org.redisson.RedissonObject
org.redisson.RedissonAtomicDouble
All Implemented Interfaces:
RAtomicDouble, RAtomicDoubleAsync, RExpirable, RExpirableAsync, RObject, RObjectAsync

public class RedissonAtomicDouble extends RedissonObject implements RAtomicDouble
Distributed alternative to the AtomicLong
Author:
Nikita Koksharov
  • Constructor Details

  • Method Details

    • addAndGet

      public double addAndGet(double delta)
      Description copied from interface: RAtomicDouble
      Atomically adds the given value to the current value.
      Specified by:
      addAndGet in interface RAtomicDouble
      Parameters:
      delta - the value to add
      Returns:
      the updated value
    • addAndGetAsync

      public RFuture<Double> addAndGetAsync(double delta)
      Description copied from interface: RAtomicDoubleAsync
      Atomically adds the given value to the current value.
      Specified by:
      addAndGetAsync in interface RAtomicDoubleAsync
      Parameters:
      delta - the value to add
      Returns:
      the updated value
    • compareAndSet

      public boolean compareAndSet(double expect, double update)
      Description copied from interface: RAtomicDouble
      Atomically sets the value to the given updated value only if the current value == the expected value.
      Specified by:
      compareAndSet in interface RAtomicDouble
      Parameters:
      expect - the expected value
      update - the new value
      Returns:
      true if successful; or false if the actual value was not equal to the expected value.
    • compareAndSetAsync

      public RFuture<Boolean> compareAndSetAsync(double expect, double update)
      Description copied from interface: RAtomicDoubleAsync
      Atomically sets the value to the given updated value only if the current value == the expected value.
      Specified by:
      compareAndSetAsync in interface RAtomicDoubleAsync
      Parameters:
      expect - the expected value
      update - the new value
      Returns:
      true if successful; or false if the actual value was not equal to the expected value.
    • decrementAndGet

      public double decrementAndGet()
      Description copied from interface: RAtomicDouble
      Atomically decrements the current value by one.
      Specified by:
      decrementAndGet in interface RAtomicDouble
      Returns:
      the updated value
    • decrementAndGetAsync

      public RFuture<Double> decrementAndGetAsync()
      Description copied from interface: RAtomicDoubleAsync
      Atomically decrements the current value by one.
      Specified by:
      decrementAndGetAsync in interface RAtomicDoubleAsync
      Returns:
      the updated value
    • get

      public double get()
      Description copied from interface: RAtomicDouble
      Returns current value.
      Specified by:
      get in interface RAtomicDouble
      Returns:
      current value
    • getAndDelete

      public double getAndDelete()
      Description copied from interface: RAtomicDouble
      Returns and deletes object
      Specified by:
      getAndDelete in interface RAtomicDouble
      Returns:
      the current value
    • getAndDeleteAsync

      public RFuture<Double> getAndDeleteAsync()
      Description copied from interface: RAtomicDoubleAsync
      Returns and deletes object
      Specified by:
      getAndDeleteAsync in interface RAtomicDoubleAsync
      Returns:
      the current value
    • getAsync

      public RFuture<Double> getAsync()
      Description copied from interface: RAtomicDoubleAsync
      Returns current value.
      Specified by:
      getAsync in interface RAtomicDoubleAsync
      Returns:
      current value
    • getAndAdd

      public double getAndAdd(double delta)
      Description copied from interface: RAtomicDouble
      Atomically adds the given value to the current value.
      Specified by:
      getAndAdd in interface RAtomicDouble
      Parameters:
      delta - the value to add
      Returns:
      the old value before the add
    • getAndAddAsync

      public RFuture<Double> getAndAddAsync(double delta)
      Description copied from interface: RAtomicDoubleAsync
      Atomically adds the given value to the current value.
      Specified by:
      getAndAddAsync in interface RAtomicDoubleAsync
      Parameters:
      delta - the value to add
      Returns:
      the updated value
    • getAndSet

      public double getAndSet(double newValue)
      Description copied from interface: RAtomicDouble
      Atomically sets the given value and returns the old value.
      Specified by:
      getAndSet in interface RAtomicDouble
      Parameters:
      newValue - the new value
      Returns:
      the old value
    • getAndSetAsync

      public RFuture<Double> getAndSetAsync(double newValue)
      Description copied from interface: RAtomicDoubleAsync
      Atomically sets the given value and returns the old value.
      Specified by:
      getAndSetAsync in interface RAtomicDoubleAsync
      Parameters:
      newValue - the new value
      Returns:
      the old value
    • incrementAndGet

      public double incrementAndGet()
      Description copied from interface: RAtomicDouble
      Atomically increments the current value by one.
      Specified by:
      incrementAndGet in interface RAtomicDouble
      Returns:
      the updated value
    • incrementAndGetAsync

      public RFuture<Double> incrementAndGetAsync()
      Description copied from interface: RAtomicDoubleAsync
      Atomically increments the current value by one.
      Specified by:
      incrementAndGetAsync in interface RAtomicDoubleAsync
      Returns:
      the updated value
    • getAndIncrement

      public double getAndIncrement()
      Description copied from interface: RAtomicDouble
      Atomically increments the current value by one.
      Specified by:
      getAndIncrement in interface RAtomicDouble
      Returns:
      the old value
    • getAndIncrementAsync

      public RFuture<Double> getAndIncrementAsync()
      Description copied from interface: RAtomicDoubleAsync
      Atomically increments the current value by one.
      Specified by:
      getAndIncrementAsync in interface RAtomicDoubleAsync
      Returns:
      the old value
    • getAndDecrement

      public double getAndDecrement()
      Description copied from interface: RAtomicDouble
      Atomically decrements by one the current value.
      Specified by:
      getAndDecrement in interface RAtomicDouble
      Returns:
      the previous value
    • getAndDecrementAsync

      public RFuture<Double> getAndDecrementAsync()
      Description copied from interface: RAtomicDoubleAsync
      Atomically decrements by one the current value.
      Specified by:
      getAndDecrementAsync in interface RAtomicDoubleAsync
      Returns:
      the previous value
    • set

      public void set(double newValue)
      Description copied from interface: RAtomicDouble
      Atomically sets the given value.
      Specified by:
      set in interface RAtomicDouble
      Parameters:
      newValue - the new value
    • setAsync

      public RFuture<Void> setAsync(double newValue)
      Description copied from interface: RAtomicDoubleAsync
      Atomically sets the given value.
      Specified by:
      setAsync in interface RAtomicDoubleAsync
      Parameters:
      newValue - the new value
      Returns:
      void
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • expire

      public boolean expire(long timeToLive, TimeUnit timeUnit)
      Description copied from interface: RExpirable
      Specified by:
      expire in interface RExpirable
      Parameters:
      timeToLive - - timeout before object will be deleted
      timeUnit - - timeout time unit
      Returns:
      true if the timeout was set and false if not
    • expireAsync

      public RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit)
      Description copied from interface: RExpirableAsync
      Specified by:
      expireAsync in interface RExpirableAsync
      Parameters:
      timeToLive - - timeout before object will be deleted
      timeUnit - - timeout time unit
      Returns:
      true if the timeout was set and false if not
    • expireAt

      public boolean expireAt(long timestamp)
      Description copied from interface: RExpirable
      Specified by:
      expireAt in interface RExpirable
      Parameters:
      timestamp - - expire date in milliseconds (Unix timestamp)
      Returns:
      true if the timeout was set and false if not
    • expireAtAsync

      public RFuture<Boolean> expireAtAsync(long timestamp)
      Description copied from interface: RExpirableAsync
      Specified by:
      expireAtAsync in interface RExpirableAsync
      Parameters:
      timestamp - - expire date in milliseconds (Unix timestamp)
      Returns:
      true if the timeout was set and false if not
    • expire

      public boolean expire(Instant instant)
      Description copied from interface: RExpirable
      Sets an expiration date for this object. When expire date comes the key will automatically be deleted.
      Specified by:
      expire in interface RExpirable
      Parameters:
      instant - expire date
      Returns:
      true if the timeout was set and false if not
    • expireIfSet

      public boolean expireIfSet(Instant time)
      Description copied from interface: RExpirable
      Sets an expiration date for this object only if it has been already set. When expire date comes the object will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfSet in interface RExpirable
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • expireIfSetAsync

      public RFuture<Boolean> expireIfSetAsync(Instant time)
      Description copied from interface: RExpirableAsync
      Sets an expiration date for this object only if it has been already set. When expire date comes the object will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfSetAsync in interface RExpirableAsync
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • expireIfNotSet

      public boolean expireIfNotSet(Instant time)
      Description copied from interface: RExpirable
      Sets an expiration date for this object only if it hasn't been set before. When expire date comes the object will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfNotSet in interface RExpirable
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • expireIfNotSetAsync

      public RFuture<Boolean> expireIfNotSetAsync(Instant time)
      Description copied from interface: RExpirableAsync
      Sets an expiration date for this object only if it hasn't been set before. When expire date comes the object will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfNotSetAsync in interface RExpirableAsync
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • expireIfGreater

      public boolean expireIfGreater(Instant time)
      Description copied from interface: RExpirable
      Sets an expiration date for this object only if it's greater than expiration date set before. When expire date comes the object will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfGreater in interface RExpirable
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • expireIfGreaterAsync

      public RFuture<Boolean> expireIfGreaterAsync(Instant time)
      Description copied from interface: RExpirableAsync
      Sets an expiration date for this object only if it's greater than expiration date set before. When expire date comes the object will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfGreaterAsync in interface RExpirableAsync
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • expireIfLess

      public boolean expireIfLess(Instant time)
      Description copied from interface: RExpirable
      Sets an expiration date for this object only if it's less than expiration date set before. When expire date comes the object will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfLess in interface RExpirable
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • expireIfLessAsync

      public RFuture<Boolean> expireIfLessAsync(Instant time)
      Description copied from interface: RExpirableAsync
      Sets an expiration date for this object only if it's less than expiration date set before. When expire date comes the object will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfLessAsync in interface RExpirableAsync
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • expireAsync

      public RFuture<Boolean> expireAsync(Instant instant)
      Description copied from interface: RExpirableAsync
      Set an expire date for object. When expire date comes the key will automatically be deleted.
      Specified by:
      expireAsync in interface RExpirableAsync
      Parameters:
      instant - - expire date
      Returns:
      true if the timeout was set and false if not
    • expire

      public boolean expire(Duration duration)
      Description copied from interface: RExpirable
      Sets a timeout for this object. After the timeout has expired, the key will automatically be deleted.
      Specified by:
      expire in interface RExpirable
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireAsync

      public RFuture<Boolean> expireAsync(Duration duration)
      Description copied from interface: RExpirableAsync
      Set a timeout for object. After the timeout has expired, the key will automatically be deleted.
      Specified by:
      expireAsync in interface RExpirableAsync
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireAt

      public boolean expireAt(Date timestamp)
      Description copied from interface: RExpirable
      Specified by:
      expireAt in interface RExpirable
      Parameters:
      timestamp - - expire date
      Returns:
      true if the timeout was set and false if not
    • expireAtAsync

      public RFuture<Boolean> expireAtAsync(Date timestamp)
      Description copied from interface: RExpirableAsync
      Specified by:
      expireAtAsync in interface RExpirableAsync
      Parameters:
      timestamp - - expire date
      Returns:
      true if the timeout was set and false if not
    • expireIfSet

      public boolean expireIfSet(Duration duration)
      Description copied from interface: RExpirable
      Sets a timeout for this object only if it has been already set. After the timeout has expired, the key will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfSet in interface RExpirable
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireIfSetAsync

      public RFuture<Boolean> expireIfSetAsync(Duration duration)
      Description copied from interface: RExpirableAsync
      Sets a timeout for this object only if it has been already set. After the timeout has expired, the key will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfSetAsync in interface RExpirableAsync
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireIfNotSet

      public boolean expireIfNotSet(Duration duration)
      Description copied from interface: RExpirable
      Sets a timeout for this object only if it hasn't been set before. After the timeout has expired, the key will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfNotSet in interface RExpirable
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireIfNotSetAsync

      public RFuture<Boolean> expireIfNotSetAsync(Duration duration)
      Description copied from interface: RExpirableAsync
      Sets a timeout for this object only if it hasn't been set before. After the timeout has expired, the key will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfNotSetAsync in interface RExpirableAsync
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireIfGreater

      public boolean expireIfGreater(Duration duration)
      Description copied from interface: RExpirable
      Sets a timeout for this object only if it's greater than timeout set before. After the timeout has expired, the key will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfGreater in interface RExpirable
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireIfGreaterAsync

      public RFuture<Boolean> expireIfGreaterAsync(Duration duration)
      Description copied from interface: RExpirableAsync
      Sets a timeout for this object only if it's greater than timeout set before. After the timeout has expired, the key will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfGreaterAsync in interface RExpirableAsync
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireIfLess

      public boolean expireIfLess(Duration duration)
      Description copied from interface: RExpirable
      Sets a timeout for this object only if it's less than timeout set before. After the timeout has expired, the key will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfLess in interface RExpirable
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireIfLessAsync

      public RFuture<Boolean> expireIfLessAsync(Duration duration)
      Description copied from interface: RExpirableAsync
      Sets a timeout for this object only if it's less than timeout set before. After the timeout has expired, the key will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfLessAsync in interface RExpirableAsync
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • clearExpire

      public boolean clearExpire()
      Description copied from interface: RExpirable
      Clear an expire timeout or expire date for object.
      Specified by:
      clearExpire in interface RExpirable
      Returns:
      true if timeout was removed false if object does not exist or does not have an associated timeout
    • clearExpireAsync

      public RFuture<Boolean> clearExpireAsync()
      Description copied from interface: RExpirableAsync
      Clear an expire timeout or expire date for object in async mode. Object will not be deleted.
      Specified by:
      clearExpireAsync in interface RExpirableAsync
      Returns:
      true if the timeout was cleared and false if not
    • remainTimeToLive

      public long remainTimeToLive()
      Description copied from interface: RExpirable
      Remaining time to live of Redisson object that has a timeout
      Specified by:
      remainTimeToLive in interface RExpirable
      Returns:
      time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expire.
    • remainTimeToLiveAsync

      public RFuture<Long> remainTimeToLiveAsync()
      Description copied from interface: RExpirableAsync
      Remaining time to live of Redisson object that has a timeout
      Specified by:
      remainTimeToLiveAsync in interface RExpirableAsync
      Returns:
      time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expire.
    • getExpireTime

      public long getExpireTime()
      Description copied from interface: RExpirable
      Expiration time of Redisson object that has a timeout

      Requires Redis 7.0.0 and higher.

      Specified by:
      getExpireTime in interface RExpirable
      Returns:
      expiration time
    • getExpireTimeAsync

      public RFuture<Long> getExpireTimeAsync()
      Description copied from interface: RExpirableAsync
      Expiration time of Redisson object that has a timeout

      Requires Redis 7.0.0 and higher.

      Specified by:
      getExpireTimeAsync in interface RExpirableAsync
      Returns:
      expiration time
    • expireAsync

      protected RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit, String param, String... keys)
    • expireAtAsync

      protected RFuture<Boolean> expireAtAsync(long timestamp, String param, String... keys)
    • clearExpireAsync

      protected RFuture<Boolean> clearExpireAsync(String... keys)