Package org.redisson
Class RedissonSemaphore
java.lang.Object
org.redisson.RedissonObject
org.redisson.RedissonSemaphore
- All Implemented Interfaces:
RExpirable
,RExpirableAsync
,RObject
,RObjectAsync
,RSemaphore
,RSemaphoreAsync
- Direct Known Subclasses:
RedissonQueueSemaphore
Distributed and concurrent implementation of
Semaphore
.
Works in non-fair mode. Therefore order of acquiring is unpredictable.
- Author:
- Nikita Koksharov
-
Field Summary
Fields inherited from class org.redisson.RedissonObject
codec, commandExecutor, name
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
acquire()
Acquires a permit.void
acquire
(int permits) Acquires defined amount ofpermits
.Acquires a permit.acquireAsync
(int permits) Acquires defined amount ofpermits
.void
addPermits
(int permits) Increases or decreases the number of available permits by defined value.addPermitsAsync
(int permits) Increases or decreases the number of available permits by defined value.int
Returns amount of available permits.Returns amount of available permits.boolean
Clear an expire timeout or expire date for object.Clear an expire timeout or expire date for object in async mode.clearExpireAsync
(String... keys) int
Acquires and returns all permits that are immediately available.Acquires and returns all permits that are immediately available.boolean
UseRExpirable.expire(Duration)
insteadboolean
Sets a timeout for this object.boolean
Sets an expiration date for this object.expireAsync
(long timeToLive, TimeUnit timeUnit) UseRExpirableAsync.expireAsync(Duration)
insteadexpireAsync
(long timeToLive, TimeUnit timeUnit, String param, String... keys) expireAsync
(Duration duration) Set a timeout for object.expireAsync
(Instant instant) Set an expire date for object.boolean
expireAt
(long timestamp) UseRExpirable.expire(Instant)
insteadboolean
UseRExpirable.expire(Instant)
insteadexpireAtAsync
(long timestamp) UseRExpirableAsync.expireAsync(Instant)
insteadexpireAtAsync
(long timestamp, String param, String... keys) expireAtAsync
(Date timestamp) UseRExpirableAsync.expireAsync(Instant)
insteadboolean
expireIfGreater
(Duration duration) Sets a timeout for this object only if it's greater than timeout set before.boolean
expireIfGreater
(Instant time) Sets an expiration date for this object only if it's greater than expiration date set before.expireIfGreaterAsync
(Duration duration) Sets a timeout for this object only if it's greater than timeout set before.expireIfGreaterAsync
(Instant time) Sets an expiration date for this object only if it's greater than expiration date set before.boolean
expireIfLess
(Duration duration) Sets a timeout for this object only if it's less than timeout set before.boolean
expireIfLess
(Instant time) Sets an expiration date for this object only if it's less than expiration date set before.expireIfLessAsync
(Duration duration) Sets a timeout for this object only if it's less than timeout set before.expireIfLessAsync
(Instant time) Sets an expiration date for this object only if it's less than expiration date set before.boolean
expireIfNotSet
(Duration duration) Sets a timeout for this object only if it hasn't been set before.boolean
expireIfNotSet
(Instant time) Sets an expiration date for this object only if it hasn't been set before.expireIfNotSetAsync
(Duration duration) Sets a timeout for this object only if it hasn't been set before.expireIfNotSetAsync
(Instant time) Sets an expiration date for this object only if it hasn't been set before.boolean
expireIfSet
(Duration duration) Sets a timeout for this object only if it has been already set.boolean
expireIfSet
(Instant time) Sets an expiration date for this object only if it has been already set.expireIfSetAsync
(Duration duration) Sets a timeout for this object only if it has been already set.expireIfSetAsync
(Instant time) Sets an expiration date for this object only if it has been already set.static String
getChannelName
(String name) long
Returns expiration time of the object as the absolute Unix expiration timestamp in milliseconds.Returns expiration time of the object as the absolute Unix expiration timestamp in milliseconds.void
release()
Releases a permit.void
release
(int permits) Releases defined amount ofpermits
.Releases a permit.releaseAsync
(int permits) Releases defined amount ofpermits
.long
Returns remaining time of the object in milliseconds.Returns remaining time of the object in milliseconds.boolean
Tries to acquire currently available permit.boolean
tryAcquire
(int permits) Tries to acquire defined amount of currently availablepermits
.boolean
tryAcquire
(int permits, long waitTime, TimeUnit unit) UseRSemaphore.tryAcquire(int, Duration)
insteadboolean
tryAcquire
(int permits, Duration waitTime) Tries to acquire defined amount of currently availablepermits
.boolean
tryAcquire
(long time, TimeUnit unit) UseRSemaphore.tryAcquire(Duration)
insteadboolean
tryAcquire
(Duration waitTime) Tries to acquire currently available permit.Acquires a permit.tryAcquireAsync
(int permits) Tries to acquire defined amount of currently availablepermits
.tryAcquireAsync
(int permits, long waitTime, TimeUnit unit) UseRSemaphoreAsync.tryAcquireAsync(int, Duration)
insteadtryAcquireAsync
(int permits, Duration waitTime) Tries to acquire defined amount of currently availablepermits
.tryAcquireAsync
(long waitTime, TimeUnit unit) UseRSemaphoreAsync.tryAcquireAsync(Duration)
insteadtryAcquireAsync
(Duration waitTime) Tries to acquire currently available permit.boolean
trySetPermits
(int permits) Tries to set number of permits.boolean
trySetPermits
(int permits, Duration timeToLive) Tries to set number of permits with defined time to live.trySetPermitsAsync
(int permits) Tries to set number of permits.trySetPermitsAsync
(int permits, Duration timeToLive) Tries to set number of permits with defined time to live.Methods inherited from class org.redisson.RedissonObject
addListener, addListener, addListener, addListenerAsync, addListenerAsync, addListenerAsync, addListenerId, addTrackingListener, addTrackingListenerAsync, checkNotBatch, copy, copy, copy, copyAndReplace, copyAndReplace, copyAndReplaceAsync, copyAndReplaceAsync, copyAsync, copyAsync, copyAsync, copyAsync, copyAsync, delete, deleteAsync, deleteAsync, dump, dumpAsync, encode, encode, encode, encode, encodeMapKey, encodeMapKey, encodeMapKeys, encodeMapValue, encodeMapValues, get, getCodec, getIdleTime, getIdleTimeAsync, getListenerIdsByName, getLockByMapKey, getLockByValue, getName, getNameByListenerId, getRawName, getRawName, getServiceManager, getSubscribeService, isExists, isExistsAsync, map, mapName, migrate, migrateAsync, move, moveAsync, prefixName, removeListener, removeListener, removeListenerAsync, removeListenerAsync, removeListenerAsync, removeListenerId, removeListeners, removeTrackingListener, removeTrackingListenerAsync, rename, renameAsync, renameAsync, renameAsync, renamenx, renamenxAsync, renamenxAsync, renamenxAsync, restore, restore, restoreAndReplace, restoreAndReplace, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, setName, sizeInMemory, sizeInMemoryAsync, sizeInMemoryAsync, sizeInMemoryAsync, suffixName, toSeconds, toStream, touch, touchAsync, unlink, unlinkAsync
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.redisson.api.RExpirable
clearExpire, expire, expire, expire, expireAt, expireAt, expireIfGreater, expireIfGreater, expireIfLess, expireIfLess, expireIfNotSet, expireIfNotSet, expireIfSet, expireIfSet, getExpireTime, remainTimeToLive
Methods inherited from interface org.redisson.api.RExpirableAsync
clearExpireAsync, expireAsync, expireAsync, expireAsync, expireAtAsync, expireAtAsync, expireIfGreaterAsync, expireIfGreaterAsync, expireIfLessAsync, expireIfLessAsync, expireIfNotSetAsync, expireIfNotSetAsync, expireIfSetAsync, expireIfSetAsync, getExpireTimeAsync, remainTimeToLiveAsync
Methods inherited from interface org.redisson.api.RObject
addListener, copy, copy, copy, copyAndReplace, copyAndReplace, delete, dump, getCodec, getIdleTime, getName, isExists, migrate, move, removeListener, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlink
Methods inherited from interface org.redisson.api.RObjectAsync
addListenerAsync, copyAndReplaceAsync, copyAndReplaceAsync, copyAsync, copyAsync, copyAsync, deleteAsync, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync, touchAsync, unlinkAsync
-
Constructor Details
-
RedissonSemaphore
-
-
Method Details
-
getChannelName
-
acquire
Description copied from interface:RSemaphore
Acquires a permit. Waits if necessary until a permit became available.- Specified by:
acquire
in interfaceRSemaphore
- Throws:
InterruptedException
- if the current thread was interrupted
-
acquire
Description copied from interface:RSemaphore
Acquires defined amount ofpermits
. Waits if necessary until all permits became available.- Specified by:
acquire
in interfaceRSemaphore
- Parameters:
permits
- the number of permits to acquire- Throws:
InterruptedException
- if the current thread is interrupted
-
acquireAsync
Description copied from interface:RSemaphoreAsync
Acquires a permit. Waits if necessary until a permit became available.- Specified by:
acquireAsync
in interfaceRSemaphoreAsync
- Returns:
- void
-
acquireAsync
Description copied from interface:RSemaphoreAsync
Acquires defined amount ofpermits
. Waits if necessary until all permits became available.- Specified by:
acquireAsync
in interfaceRSemaphoreAsync
- Parameters:
permits
- the number of permits to acquire- Returns:
- void
-
tryAcquire
public boolean tryAcquire()Description copied from interface:RSemaphore
Tries to acquire currently available permit.- Specified by:
tryAcquire
in interfaceRSemaphore
- Returns:
true
if a permit was acquired andfalse
otherwise
-
tryAcquire
public boolean tryAcquire(int permits) Description copied from interface:RSemaphore
Tries to acquire defined amount of currently availablepermits
.- Specified by:
tryAcquire
in interfaceRSemaphore
- Parameters:
permits
- the number of permits to acquire- Returns:
true
if permits were acquired andfalse
otherwise
-
tryAcquireAsync
Description copied from interface:RSemaphoreAsync
Acquires a permit. Waits if necessary until a permit became available.- Specified by:
tryAcquireAsync
in interfaceRSemaphoreAsync
- Returns:
true
if a permit was acquired andfalse
otherwise
-
tryAcquireAsync
Description copied from interface:RSemaphoreAsync
Tries to acquire defined amount of currently availablepermits
.- Specified by:
tryAcquireAsync
in interfaceRSemaphoreAsync
- Parameters:
permits
- the number of permits to acquire- Returns:
true
if permits were acquired andfalse
otherwise
-
tryAcquireAsync
Description copied from interface:RSemaphoreAsync
UseRSemaphoreAsync.tryAcquireAsync(Duration)
instead- Specified by:
tryAcquireAsync
in interfaceRSemaphoreAsync
- Parameters:
waitTime
- the maximum time to waitunit
- the time unit- Returns:
true
if a permit was acquired andfalse
otherwise
-
tryAcquire
Description copied from interface:RSemaphore
Tries to acquire currently available permit. Waits up to definedwaitTime
if necessary until a permit became available.- Specified by:
tryAcquire
in interfaceRSemaphore
- Parameters:
waitTime
- the maximum time to wait- Returns:
true
if a permit was acquired andfalse
otherwise- Throws:
InterruptedException
- if the current thread was interrupted
-
tryAcquire
Description copied from interface:RSemaphore
Tries to acquire defined amount of currently availablepermits
. Waits up to definedwaitTime
if necessary until all permits became available.- Specified by:
tryAcquire
in interfaceRSemaphore
- Parameters:
permits
- amount of permitswaitTime
- the maximum time to wait- Returns:
true
if permits were acquired andfalse
otherwise- Throws:
InterruptedException
- if the current thread was interrupted
-
tryAcquireAsync
Description copied from interface:RSemaphoreAsync
Tries to acquire currently available permit. Waits up to definedwaitTime
if necessary until a permit became available.- Specified by:
tryAcquireAsync
in interfaceRSemaphoreAsync
- Parameters:
waitTime
- the maximum time to wait- Returns:
true
if a permit was acquired andfalse
otherwise
-
tryAcquireAsync
Description copied from interface:RSemaphoreAsync
Tries to acquire defined amount of currently availablepermits
. Waits up to definedwaitTime
if necessary until all permits became available.- Specified by:
tryAcquireAsync
in interfaceRSemaphoreAsync
- Parameters:
permits
- amount of permitswaitTime
- the maximum time to wait- Returns:
true
if permits were acquired andfalse
otherwise
-
tryAcquire
Description copied from interface:RSemaphore
UseRSemaphore.tryAcquire(int, Duration)
instead- Specified by:
tryAcquire
in interfaceRSemaphore
- Parameters:
permits
- amount of permitswaitTime
- the maximum time to waitunit
- the time unit- Returns:
true
if permits were acquired andfalse
otherwise- Throws:
InterruptedException
- if the current thread was interrupted
-
tryAcquireAsync
Description copied from interface:RSemaphoreAsync
UseRSemaphoreAsync.tryAcquireAsync(int, Duration)
instead- Specified by:
tryAcquireAsync
in interfaceRSemaphoreAsync
- Parameters:
permits
- amount of permitswaitTime
- the maximum time to waitunit
- the time unit- Returns:
true
if permits were acquired andfalse
otherwise
-
tryAcquire
Description copied from interface:RSemaphore
UseRSemaphore.tryAcquire(Duration)
instead- Specified by:
tryAcquire
in interfaceRSemaphore
- Parameters:
time
- the maximum time to waitunit
- the time unit- Returns:
true
if a permit was acquired andfalse
otherwise- Throws:
InterruptedException
- if the current thread was interrupted
-
release
public void release()Description copied from interface:RSemaphore
Releases a permit. Increases the number of available permits.- Specified by:
release
in interfaceRSemaphore
-
release
public void release(int permits) Description copied from interface:RSemaphore
Releases defined amount ofpermits
. Increases the number of available permits bypermits
amount.- Specified by:
release
in interfaceRSemaphore
- Parameters:
permits
- amount of permits
-
releaseAsync
Description copied from interface:RSemaphoreAsync
Releases a permit.- Specified by:
releaseAsync
in interfaceRSemaphoreAsync
- Returns:
- void
-
releaseAsync
Description copied from interface:RSemaphoreAsync
Releases defined amount ofpermits
.- Specified by:
releaseAsync
in interfaceRSemaphoreAsync
- Parameters:
permits
- amount- Returns:
- void
-
drainPermits
public int drainPermits()Description copied from interface:RSemaphore
Acquires and returns all permits that are immediately available.- Specified by:
drainPermits
in interfaceRSemaphore
- Returns:
- number of permits
-
drainPermitsAsync
Description copied from interface:RSemaphoreAsync
Acquires and returns all permits that are immediately available.- Specified by:
drainPermitsAsync
in interfaceRSemaphoreAsync
- Returns:
- number of permits
-
availablePermits
public int availablePermits()Description copied from interface:RSemaphore
Returns amount of available permits.- Specified by:
availablePermits
in interfaceRSemaphore
- Returns:
- number of permits
-
availablePermitsAsync
Description copied from interface:RSemaphoreAsync
Returns amount of available permits.- Specified by:
availablePermitsAsync
in interfaceRSemaphoreAsync
- Returns:
- number of permits
-
trySetPermits
public boolean trySetPermits(int permits) Description copied from interface:RSemaphore
Tries to set number of permits.- Specified by:
trySetPermits
in interfaceRSemaphore
- Parameters:
permits
- number of permits- Returns:
true
if permits has been set successfully, otherwisefalse
if permits were already set.
-
trySetPermitsAsync
Description copied from interface:RSemaphoreAsync
Tries to set number of permits.- Specified by:
trySetPermitsAsync
in interfaceRSemaphoreAsync
- Parameters:
permits
- number of permits- Returns:
true
if permits has been set successfully, otherwisefalse
.
-
trySetPermits
Description copied from interface:RSemaphore
Tries to set number of permits with defined time to live.- Specified by:
trySetPermits
in interfaceRSemaphore
- Parameters:
permits
- number of permitstimeToLive
- time to live- Returns:
true
if permits has been set successfully, otherwisefalse
if permits were already set.
-
trySetPermitsAsync
Description copied from interface:RSemaphoreAsync
Tries to set number of permits with defined time to live.- Specified by:
trySetPermitsAsync
in interfaceRSemaphoreAsync
- Parameters:
permits
- number of permitstimeToLive
- time to live- Returns:
true
if permits has been set successfully, otherwisefalse
.
-
addPermits
public void addPermits(int permits) Description copied from interface:RSemaphore
Increases or decreases the number of available permits by defined value.- Specified by:
addPermits
in interfaceRSemaphore
- Parameters:
permits
- amount of permits to add/remove
-
addPermitsAsync
Description copied from interface:RSemaphoreAsync
Increases or decreases the number of available permits by defined value.- Specified by:
addPermitsAsync
in interfaceRSemaphoreAsync
- Parameters:
permits
- amount of permits to add/remove
-
expire
Description copied from interface:RExpirable
UseRExpirable.expire(Duration)
instead- Specified by:
expire
in interfaceRExpirable
- Parameters:
timeToLive
- - timeout before object will be deletedtimeUnit
- - timeout time unit- Returns:
true
if the timeout was set andfalse
if not
-
expireAsync
Description copied from interface:RExpirableAsync
UseRExpirableAsync.expireAsync(Duration)
instead- Specified by:
expireAsync
in interfaceRExpirableAsync
- Parameters:
timeToLive
- - timeout before object will be deletedtimeUnit
- - timeout time unit- Returns:
true
if the timeout was set andfalse
if not
-
expireAt
public boolean expireAt(long timestamp) Description copied from interface:RExpirable
UseRExpirable.expire(Instant)
instead- Specified by:
expireAt
in interfaceRExpirable
- Parameters:
timestamp
- - expire date in milliseconds (Unix timestamp)- Returns:
true
if the timeout was set andfalse
if not
-
expireAtAsync
Description copied from interface:RExpirableAsync
UseRExpirableAsync.expireAsync(Instant)
instead- Specified by:
expireAtAsync
in interfaceRExpirableAsync
- Parameters:
timestamp
- - expire date in milliseconds (Unix timestamp)- Returns:
true
if the timeout was set andfalse
if not
-
expire
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 interfaceRExpirable
- Parameters:
instant
- expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireIfSet
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 interfaceRExpirable
- Parameters:
time
- expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireIfSetAsync
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 interfaceRExpirableAsync
- Parameters:
time
- expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireIfNotSet
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 interfaceRExpirable
- Parameters:
time
- expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireIfNotSetAsync
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 interfaceRExpirableAsync
- Parameters:
time
- expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireIfGreater
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 interfaceRExpirable
- Parameters:
time
- expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireIfGreaterAsync
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 interfaceRExpirableAsync
- Parameters:
time
- expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireIfLess
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 interfaceRExpirable
- Parameters:
time
- expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireIfLessAsync
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 interfaceRExpirableAsync
- Parameters:
time
- expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireAsync
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 interfaceRExpirableAsync
- Parameters:
instant
- - expire date- Returns:
true
if the timeout was set andfalse
if not
-
expire
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 interfaceRExpirable
- Parameters:
duration
- timeout before object will be deleted- Returns:
true
if the timeout was set andfalse
if not
-
expireAsync
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 interfaceRExpirableAsync
- Parameters:
duration
- timeout before object will be deleted- Returns:
true
if the timeout was set andfalse
if not
-
expireAt
Description copied from interface:RExpirable
UseRExpirable.expire(Instant)
instead- Specified by:
expireAt
in interfaceRExpirable
- Parameters:
timestamp
- - expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireAtAsync
Description copied from interface:RExpirableAsync
UseRExpirableAsync.expireAsync(Instant)
instead- Specified by:
expireAtAsync
in interfaceRExpirableAsync
- Parameters:
timestamp
- - expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireIfSet
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 interfaceRExpirable
- Parameters:
duration
- timeout before object will be deleted- Returns:
true
if the timeout was set andfalse
if not
-
expireIfSetAsync
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 interfaceRExpirableAsync
- Parameters:
duration
- timeout before object will be deleted- Returns:
true
if the timeout was set andfalse
if not
-
expireIfNotSet
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 interfaceRExpirable
- Parameters:
duration
- timeout before object will be deleted- Returns:
true
if the timeout was set andfalse
if not
-
expireIfNotSetAsync
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 interfaceRExpirableAsync
- Parameters:
duration
- timeout before object will be deleted- Returns:
true
if the timeout was set andfalse
if not
-
expireIfGreater
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 interfaceRExpirable
- Parameters:
duration
- timeout before object will be deleted- Returns:
true
if the timeout was set andfalse
if not
-
expireIfGreaterAsync
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 interfaceRExpirableAsync
- Parameters:
duration
- timeout before object will be deleted- Returns:
true
if the timeout was set andfalse
if not
-
expireIfLess
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 interfaceRExpirable
- Parameters:
duration
- timeout before object will be deleted- Returns:
true
if the timeout was set andfalse
if not
-
expireIfLessAsync
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 interfaceRExpirableAsync
- Parameters:
duration
- timeout before object will be deleted- Returns:
true
if the timeout was set andfalse
if not
-
clearExpire
public boolean clearExpire()Description copied from interface:RExpirable
Clear an expire timeout or expire date for object.- Specified by:
clearExpire
in interfaceRExpirable
- Returns:
true
if timeout was removedfalse
if object does not exist or does not have an associated timeout
-
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 interfaceRExpirableAsync
- Returns:
true
if the timeout was cleared andfalse
if not
-
remainTimeToLive
public long remainTimeToLive()Description copied from interface:RExpirable
Returns remaining time of the object in milliseconds.- Specified by:
remainTimeToLive
in interfaceRExpirable
- Returns:
- time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expire.
-
remainTimeToLiveAsync
Description copied from interface:RExpirableAsync
Returns remaining time of the object in milliseconds.- Specified by:
remainTimeToLiveAsync
in interfaceRExpirableAsync
- 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
Returns expiration time of the object as the absolute Unix expiration timestamp in milliseconds.Requires Redis 7.0.0 and higher.
- Specified by:
getExpireTime
in interfaceRExpirable
- Returns:
- Unix time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expiration time.
-
getExpireTimeAsync
Description copied from interface:RExpirableAsync
Returns expiration time of the object as the absolute Unix expiration timestamp in milliseconds.Requires Redis 7.0.0 and higher.
- Specified by:
getExpireTimeAsync
in interfaceRExpirableAsync
- Returns:
- Unix time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expiration time.
-
expireAsync
-
expireAtAsync
-
clearExpireAsync
-