public class RedissonPermitExpirableSemaphore extends RedissonObject implements RPermitExpirableSemaphore
codec, name
Constructor and Description |
---|
RedissonPermitExpirableSemaphore(CommandAsyncExecutor commandExecutor,
String name) |
Modifier and Type | Method and Description |
---|---|
String |
acquire()
Acquires a permit and returns its id.
|
String |
acquire(long leaseTime,
TimeUnit timeUnit)
Acquires a permit with defined
leaseTime and return its id. |
RFuture<String> |
acquireAsync()
Acquires a permit and returns its id.
|
RFuture<String> |
acquireAsync(long leaseTime,
TimeUnit timeUnit)
Acquires a permit with defined
leaseTime and return its id. |
void |
addPermits(int permits)
Increases or decreases the number of available permits by defined value.
|
RFuture<Void> |
addPermitsAsync(int permits)
Increases or decreases the number of available permits by defined value.
|
int |
availablePermits()
Returns amount of available permits.
|
RFuture<Integer> |
availablePermitsAsync()
Returns amount of available permits.
|
boolean |
clearExpire()
Clear an expire timeout or expire date for object.
|
RFuture<Boolean> |
clearExpireAsync()
Clear an expire timeout or expire date for object in async mode.
|
protected RFuture<Boolean> |
clearExpireAsync(String... keys) |
RFuture<Boolean> |
deleteAsync()
Delete object in async mode
|
boolean |
expire(long timeToLive,
TimeUnit timeUnit)
Set a timeout for object.
|
RFuture<Boolean> |
expireAsync(long timeToLive,
TimeUnit timeUnit)
Set a timeout for object in async mode.
|
protected RFuture<Boolean> |
expireAsync(long timeToLive,
TimeUnit timeUnit,
String... keys) |
boolean |
expireAt(Date timestamp)
Set an expire date for object.
|
boolean |
expireAt(long timestamp)
Set an expire date for object.
|
RFuture<Boolean> |
expireAtAsync(Date timestamp)
Set an expire date for object in async mode.
|
RFuture<Boolean> |
expireAtAsync(long timestamp)
Set an expire date for object in async mode.
|
protected RFuture<Boolean> |
expireAtAsync(long timestamp,
String... keys) |
protected String |
generateId() |
static String |
getChannelName(String name) |
void |
release(String permitId)
Releases a permit by its id.
|
RFuture<Void> |
releaseAsync(String permitId)
Releases a permit by its id.
|
long |
remainTimeToLive()
Remaining time to live of Redisson object that has a timeout
|
RFuture<Long> |
remainTimeToLiveAsync()
Remaining time to live of Redisson object that has a timeout
|
RFuture<Long> |
sizeInMemoryAsync()
Returns bytes amount used by object in Redis memory.
|
String |
tryAcquire()
Tries to acquire currently available permit and return its id.
|
String |
tryAcquire(long waitTime,
long ttl,
TimeUnit unit)
Tries to acquire currently available permit
with defined
leaseTime and return its id. |
String |
tryAcquire(long waitTime,
TimeUnit unit)
Tries to acquire currently available permit and return its id.
|
RFuture<String> |
tryAcquireAsync()
Tries to acquire currently available permit and return its id.
|
RFuture<String> |
tryAcquireAsync(int permits,
long timeoutDate) |
RFuture<String> |
tryAcquireAsync(long waitTime,
long ttl,
TimeUnit unit)
Tries to acquire currently available permit
with defined
leaseTime and return its id. |
RFuture<String> |
tryAcquireAsync(long waitTime,
TimeUnit unit)
Tries to acquire currently available permit and return its id.
|
boolean |
tryRelease(String permitId)
Tries to release permit by its id.
|
RFuture<Boolean> |
tryReleaseAsync(String permitId)
Tries to release permit by its id.
|
boolean |
trySetPermits(int permits)
Tries to set number of permits.
|
RFuture<Boolean> |
trySetPermitsAsync(int permits)
Tries to set number of permits.
|
boolean |
updateLeaseTime(String permitId,
long leaseTime,
TimeUnit unit)
Overrides and updates lease time for defined permit id.
|
RFuture<Boolean> |
updateLeaseTimeAsync(String permitId,
long leaseTime,
TimeUnit unit)
Overrides and updates lease time for defined permit id.
|
addListener, addListener, addListenerAsync, addListenerAsync, copy, copyAsync, delete, deleteAsync, dump, dumpAsync, encode, encode, encode, encode, encodeMapKey, encodeMapKeys, encodeMapValue, encodeMapValues, get, getCodec, getLockByMapKey, getLockByValue, getName, getName, isExists, isExistsAsync, migrate, migrateAsync, move, moveAsync, prefixName, removeListener, removeListenerAsync, removeListenersAsync, rename, renameAsync, renamenx, renamenxAsync, restore, restore, restoreAndReplace, restoreAndReplace, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemory, sizeInMemoryAsync, suffixName, toSeconds, toStream, touch, touchAsync, unlink, unlinkAsync
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clearExpire, expire, expireAt, expireAt, remainTimeToLive
addListener, copy, delete, dump, getCodec, getName, isExists, migrate, move, removeListener, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlink
expireAtAsync, remainTimeToLiveAsync
addListenerAsync, copyAsync, dumpAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, touchAsync, unlinkAsync
public RedissonPermitExpirableSemaphore(CommandAsyncExecutor commandExecutor, String name)
public String acquire() throws InterruptedException
RPermitExpirableSemaphore
acquire
in interface RPermitExpirableSemaphore
InterruptedException
- if the current thread is interruptedpublic String acquire(long leaseTime, TimeUnit timeUnit) throws InterruptedException
RPermitExpirableSemaphore
leaseTime
and return its id.
Waits if necessary until a permit became available.acquire
in interface RPermitExpirableSemaphore
leaseTime
- permit lease timetimeUnit
- time unitInterruptedException
- if the current thread is interruptedpublic RFuture<String> acquireAsync(long leaseTime, TimeUnit timeUnit)
RPermitExpirableSemaphoreAsync
leaseTime
and return its id.
Waits if necessary until a permit became available.acquireAsync
in interface RPermitExpirableSemaphoreAsync
leaseTime
- permit lease timetimeUnit
- time unitpublic RFuture<String> acquireAsync()
RPermitExpirableSemaphoreAsync
acquireAsync
in interface RPermitExpirableSemaphoreAsync
public String tryAcquire()
RPermitExpirableSemaphore
tryAcquire
in interface RPermitExpirableSemaphore
null
otherwisepublic RFuture<String> tryAcquireAsync()
RPermitExpirableSemaphoreAsync
tryAcquireAsync
in interface RPermitExpirableSemaphoreAsync
null
otherwiseprotected String generateId()
public RFuture<String> tryAcquireAsync(long waitTime, TimeUnit unit)
RPermitExpirableSemaphoreAsync
waitTime
if necessary until a permit became available.tryAcquireAsync
in interface RPermitExpirableSemaphoreAsync
waitTime
- the maximum time to waitunit
- the time unitnull
if the waiting time elapsed before a permit was acquiredpublic String tryAcquire(long waitTime, long ttl, TimeUnit unit) throws InterruptedException
RPermitExpirableSemaphore
leaseTime
and return its id.
Waits up to defined waitTime
if necessary until a permit became available.tryAcquire
in interface RPermitExpirableSemaphore
waitTime
- the maximum time to waitttl
- permit lease time, use -1 to make it permanentunit
- the time unitnull
if the waiting time elapsed before a permit was acquiredInterruptedException
- if the current thread is interruptedpublic RFuture<String> tryAcquireAsync(long waitTime, long ttl, TimeUnit unit)
RPermitExpirableSemaphoreAsync
leaseTime
and return its id.
Waits up to defined waitTime
if necessary until a permit became available.tryAcquireAsync
in interface RPermitExpirableSemaphoreAsync
waitTime
- the maximum time to waitttl
- permit lease time, use -1 to make it permanentunit
- the time unitnull
if the waiting time elapsed before a permit was acquiredpublic String tryAcquire(long waitTime, TimeUnit unit) throws InterruptedException
RPermitExpirableSemaphore
waitTime
if necessary until a permit became available.tryAcquire
in interface RPermitExpirableSemaphore
waitTime
- the maximum time to waitunit
- the time unitnull
if the waiting time elapsed before a permit was acquiredInterruptedException
- if the current thread is interruptedpublic void release(String permitId)
RPermitExpirableSemaphore
release
in interface RPermitExpirableSemaphore
permitId
- - permit idpublic boolean tryRelease(String permitId)
RPermitExpirableSemaphore
tryRelease
in interface RPermitExpirableSemaphore
permitId
- permit idtrue
if a permit has been released and false
otherwisepublic RFuture<Boolean> tryReleaseAsync(String permitId)
RPermitExpirableSemaphoreAsync
tryReleaseAsync
in interface RPermitExpirableSemaphoreAsync
permitId
- permit idtrue
if a permit has been released and false
otherwisepublic RFuture<Long> sizeInMemoryAsync()
RObjectAsync
sizeInMemoryAsync
in interface RObjectAsync
sizeInMemoryAsync
in class RedissonObject
public RFuture<Boolean> deleteAsync()
RObjectAsync
deleteAsync
in interface RObjectAsync
deleteAsync
in class RedissonObject
true
if object was deleted false
if notpublic RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit)
RExpirableAsync
expireAsync
in interface RExpirableAsync
timeToLive
- - timeout before object will be deletedtimeUnit
- - timeout time unittrue
if the timeout was set and false
if notpublic RFuture<Boolean> expireAtAsync(long timestamp)
RExpirableAsync
expireAtAsync
in interface RExpirableAsync
timestamp
- - expire date in milliseconds (Unix timestamp)true
if the timeout was set and false
if notpublic RFuture<Boolean> clearExpireAsync()
RExpirableAsync
clearExpireAsync
in interface RExpirableAsync
true
if the timeout was cleared and false
if notpublic RFuture<Void> releaseAsync(String permitId)
RPermitExpirableSemaphoreAsync
releaseAsync
in interface RPermitExpirableSemaphoreAsync
permitId
- - permit idpublic int availablePermits()
RPermitExpirableSemaphore
availablePermits
in interface RPermitExpirableSemaphore
public RFuture<Integer> availablePermitsAsync()
RPermitExpirableSemaphoreAsync
availablePermitsAsync
in interface RPermitExpirableSemaphoreAsync
public boolean trySetPermits(int permits)
RPermitExpirableSemaphore
trySetPermits
in interface RPermitExpirableSemaphore
permits
- - number of permitstrue
if permits has been set successfully, otherwise false
.public RFuture<Boolean> trySetPermitsAsync(int permits)
RPermitExpirableSemaphoreAsync
trySetPermitsAsync
in interface RPermitExpirableSemaphoreAsync
permits
- - number of permitstrue
if permits has been set successfully, otherwise false
.public void addPermits(int permits)
RPermitExpirableSemaphore
addPermits
in interface RPermitExpirableSemaphore
permits
- amount of permits to add/removepublic RFuture<Void> addPermitsAsync(int permits)
RPermitExpirableSemaphoreAsync
addPermitsAsync
in interface RPermitExpirableSemaphoreAsync
permits
- amount of permits to add/removepublic RFuture<Boolean> updateLeaseTimeAsync(String permitId, long leaseTime, TimeUnit unit)
RPermitExpirableSemaphoreAsync
updateLeaseTimeAsync
in interface RPermitExpirableSemaphoreAsync
permitId
- permit idleaseTime
- permit lease time, use -1 to make it permanentunit
- the time unittrue
if permits has been updated successfully, otherwise false
.public boolean updateLeaseTime(String permitId, long leaseTime, TimeUnit unit)
RPermitExpirableSemaphore
updateLeaseTime
in interface RPermitExpirableSemaphore
permitId
- permit idleaseTime
- permit lease time, use -1 to make it permanentunit
- the time unittrue
if permits has been updated successfully, otherwise false
.public boolean expire(long timeToLive, TimeUnit timeUnit)
RExpirable
expire
in interface RExpirable
timeToLive
- - timeout before object will be deletedtimeUnit
- - timeout time unittrue
if the timeout was set and false
if notpublic boolean expireAt(long timestamp)
RExpirable
expireAt
in interface RExpirable
timestamp
- - expire date in milliseconds (Unix timestamp)true
if the timeout was set and false
if notpublic boolean expireAt(Date timestamp)
RExpirable
expireAt
in interface RExpirable
timestamp
- - expire datetrue
if the timeout was set and false
if notpublic RFuture<Boolean> expireAtAsync(Date timestamp)
RExpirableAsync
expireAtAsync
in interface RExpirableAsync
timestamp
- - expire datetrue
if the timeout was set and false
if notpublic boolean clearExpire()
RExpirable
clearExpire
in interface RExpirable
true
if timeout was removed
false
if object does not exist or does not have an associated timeoutpublic long remainTimeToLive()
RExpirable
remainTimeToLive
in interface RExpirable
public RFuture<Long> remainTimeToLiveAsync()
RExpirableAsync
remainTimeToLiveAsync
in interface RExpirableAsync
protected RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit, String... keys)
Copyright © 2014–2020 Redisson. All rights reserved.