Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.data.redis.support.atomic
Class RedisAtomicLong

    java.lang.Object
      java.lang.Number
          org.springframework.data.redis.support.atomic.RedisAtomicLong

All Implemented Interfaces:
  Serializable, BoundKeyOperations<String>

    public class RedisAtomicLong

extends Number
implements Serializable, BoundKeyOperations<String>

Atomic long backed by Redis. Uses Redis atomic increment/decrement and watch/multi/exec operations for CAS operations.

See Also:
  `AtomicLong`, Serialized Form

Constructor Summary
`RedisAtomicLong(String redisCounter, RedisConnectionFactory factory)` Constructs a new `RedisAtomicLong` instance.
`RedisAtomicLong(String redisCounter, RedisConnectionFactory factory, long initialValue)` Constructs a new `RedisAtomicLong` instance.
`RedisAtomicLong(String redisCounter, RedisOperations<String,Long> template)` Constructs a new `RedisAtomicLong` instance.
`RedisAtomicLong(String redisCounter, RedisOperations<String,Long> template, long initialValue)` Constructs a new `RedisAtomicLong` instance.

Method Summary
`long` | `addAndGet(long delta)` Atomically adds the given value to the current value.
`boolean` | `compareAndSet(long expect, long update)` Atomically sets the value to the given updated value if the current value `==` the expected value.
`long` | `decrementAndGet()` Atomically decrements by one the current value.
`double` | `doubleValue()`
`Boolean` | `expire(long timeout, TimeUnit unit)` Sets the key time-to-live/expiration.
`Boolean` | `expireAt(Date date)` Sets the key time-to-live/expiration.
`float` | `floatValue()`
`long` | `get()` Gets the current value.
`long` | `getAndAdd(long delta)` Atomically adds the given value to the current value.
`long` | `getAndDecrement()` Atomically decrements by one the current value.
`long` | `getAndIncrement()` Atomically increments by one the current value.
`long` | `getAndSet(long newValue)` Atomically sets to the given value and returns the old value.
`Long` | `getExpire()` Returns the expiration of this key.
`String` | `getKey()` Returns the key associated with this entity.
`DataType` | `getType()` Returns the associated Redis type.
`long` | `incrementAndGet()` Atomically increments by one the current value.
`int` | `intValue()`
`long` | `longValue()`
`Boolean` | `persist()` Removes the expiration (if any) of the key.
`void` | `rename(String newKey)` Renames the key.
`void` | `set(long newValue)` Sets to the given value.
`String` | `toString()` Returns the String representation of the current value.

Methods inherited from class java.lang.Number
`byteValue, shortValue`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### RedisAtomicLong

    public RedisAtomicLong(String redisCounter,
                           RedisConnectionFactory factory)

  Constructs a new `RedisAtomicLong` instance. Uses the value existing in Redis or 0 if none is found.

  Parameters:
    `redisCounter` - redis counter
    `factory` - connection factory

### RedisAtomicLong

    public RedisAtomicLong(String redisCounter,
                           RedisConnectionFactory factory,
                           long initialValue)

  Constructs a new `RedisAtomicLong` instance.

  Parameters:
    `redisCounter` -
    `factory` -
    `initialValue` -

### RedisAtomicLong

    public RedisAtomicLong(String redisCounter,
                           RedisOperations<String,Long> template)

  Constructs a new `RedisAtomicLong` instance. Uses the value existing in Redis or 0 if none is found.

  Parameters:
    `redisCounter` - the redis counter
    `template` - the template

### RedisAtomicLong

    public RedisAtomicLong(String redisCounter,
                           RedisOperations<String,Long> template,
                           long initialValue)

  Constructs a new `RedisAtomicLong` instance.

  Parameters:
    `redisCounter` - the redis counter
    `template` - the template
    `initialValue` - the initial value

Method Detail

### get

    public long get()

  Gets the current value.

  Returns:
    the current value

### set

    public void set(long newValue)

  Sets to the given value.

  Parameters:
    `newValue` - the new value

### getAndSet

    public long getAndSet(long newValue)

  Atomically sets to the given value and returns the old value.

  Parameters:
    `newValue` - the new value
  Returns:
    the previous value

### compareAndSet

    public boolean compareAndSet(long expect,
                                 long update)

  Atomically sets the value to the given updated value if the current value `==` the expected value.

  Parameters:
    `expect` - the expected value
    `update` - the new value
  Returns:
    true if successful. False return indicates that the actual value was not equal to the expected value.

### getAndIncrement

    public long getAndIncrement()

  Atomically increments by one the current value.

  Returns:
    the previous value

### getAndDecrement

    public long getAndDecrement()

  Atomically decrements by one the current value.

  Returns:
    the previous value

### getAndAdd

    public long getAndAdd(long delta)

  Atomically adds the given value to the current value.

  Parameters:
    `delta` - the value to add
  Returns:
    the previous value

### incrementAndGet

    public long incrementAndGet()

  Atomically increments by one the current value.

  Returns:
    the updated value

### decrementAndGet

    public long decrementAndGet()

  Atomically decrements by one the current value.

  Returns:
    the updated value

### addAndGet

    public long addAndGet(long delta)

  Atomically adds the given value to the current value.

  Parameters:
    `delta` - the value to add
  Returns:
    the updated value

### toString

    public String toString()

  Returns the String representation of the current value.

  Overrides:
    `toString` in class `Object`
  Returns:
    the String representation of the current value.

### intValue

    public int intValue()

  Specified by:
    `intValue` in class `Number`

### longValue

    public long longValue()

  Specified by:
    `longValue` in class `Number`

### floatValue

    public float floatValue()

  Specified by:
    `floatValue` in class `Number`

### doubleValue

    public double doubleValue()

  Specified by:
    `doubleValue` in class `Number`

### getKey

    public String getKey()

  Description copied from interface: `BoundKeyOperations`
  Returns the key associated with this entity.

  Specified by:
    `getKey` in interface `BoundKeyOperations<String>`
  Returns:
    key associated with the implementing entity

### expire

    public Boolean expire(long timeout,
                          TimeUnit unit)

  Description copied from interface: `BoundKeyOperations`
  Sets the key time-to-live/expiration.

  Specified by:
    `expire` in interface `BoundKeyOperations<String>`
  Parameters:
    `timeout` - expiration value
    `unit` - expiration unit
  Returns:
    true if expiration was set, false otherwise

### expireAt

    public Boolean expireAt(Date date)

  Description copied from interface: `BoundKeyOperations`
  Sets the key time-to-live/expiration.

  Specified by:
    `expireAt` in interface `BoundKeyOperations<String>`
  Parameters:
    `date` - expiration date
  Returns:
    true if expiration was set, false otherwise

### getExpire

    public Long getExpire()

  Description copied from interface: `BoundKeyOperations`
  Returns the expiration of this key.

  Specified by:
    `getExpire` in interface `BoundKeyOperations<String>`
  Returns:
    expiration value (in seconds)

### persist

    public Boolean persist()

  Description copied from interface: `BoundKeyOperations`
  Removes the expiration (if any) of the key.

  Specified by:
    `persist` in interface `BoundKeyOperations<String>`
  Returns:
    true if expiration was removed, false otherwise

### rename

    public void rename(String newKey)

  Description copied from interface: `BoundKeyOperations`
  Renames the key.

  Specified by:
    `rename` in interface `BoundKeyOperations<String>`
  Parameters:
    `newKey` - new key

### getType

    public DataType getType()

  Description copied from interface: `BoundKeyOperations`
  Returns the associated Redis type.

  Specified by:
    `getType` in interface `BoundKeyOperations<String>`
  Returns:
    key type

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD