Package org.redisson
Class RedissonBloomFilter<T>
- java.lang.Object
-
- org.redisson.RedissonObject
-
- org.redisson.RedissonBloomFilter<T>
-
- Type Parameters:
T
- type of object
- All Implemented Interfaces:
RBloomFilter<T>
,RExpirable
,RExpirableAsync
,RObject
,RObjectAsync
public class RedissonBloomFilter<T> extends RedissonObject implements RBloomFilter<T>
Bloom filter based on Highway 128-bit hash.- Author:
- Nikita Koksharov
-
-
Field Summary
-
Fields inherited from class org.redisson.RedissonObject
codec, name
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
RedissonBloomFilter(Codec codec, CommandAsyncExecutor commandExecutor, String name)
protected
RedissonBloomFilter(CommandAsyncExecutor commandExecutor, String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(T object)
Adds elementboolean
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)
boolean
contains(T object)
Check for element presentlong
count()
Calculates probabilistic number of elements already added to Bloom filter.protected RBitSetAsync
createBitSet(CommandBatchService executorService)
RFuture<Boolean>
deleteAsync()
Delete object in async modeboolean
expire(long timeToLive, TimeUnit timeUnit)
Set a timeout for object.boolean
expire(Instant instant)
Set an expire date 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)
RFuture<Boolean>
expireAsync(Instant instant)
Set an expire date for object.boolean
expireAt(long timestamp)
UseRExpirable.expire(Instant)
insteadboolean
expireAt(Date timestamp)
UseRExpirable.expire(Instant)
insteadRFuture<Boolean>
expireAtAsync(long timestamp)
UseRExpirableAsync.expireAsync(Instant)
insteadprotected RFuture<Boolean>
expireAtAsync(long timestamp, String... keys)
RFuture<Boolean>
expireAtAsync(Date timestamp)
UseRExpirableAsync.expireAsync(Instant)
insteadlong
getExpectedInsertions()
Returns expected amount of insertions per element.double
getFalseProbability()
Returns false probability of element presence.int
getHashIterations()
Returns hash iterations amount used per element.protected long
getMaxSize()
long
getSize()
Returns number of bits in Redis memory required by this instanceRFuture<Boolean>
isExistsAsync()
Check object existence in async mode.long
remainTimeToLive()
Remaining time to live of Redisson object that has a timeoutRFuture<Long>
remainTimeToLiveAsync()
Remaining time to live of Redisson object that has a timeoutRFuture<Void>
renameAsync(String newName)
Rename current object key tonewName
in async modeRFuture<Boolean>
renamenxAsync(String newName)
Rename current object key tonewName
in async mode only if new key is not existsRFuture<Long>
sizeInMemoryAsync()
Returns bytes amount used by object in Redis memory.boolean
tryInit(long expectedInsertions, double falseProbability)
Initializes Bloom filter params (size and hashIterations) calculated fromexpectedInsertions
andfalseProbability
Stores config to Redis server.-
Methods inherited from class org.redisson.RedissonObject
addListener, addListener, addListenerAsync, addListenerAsync, copy, copyAsync, delete, deleteAsync, dump, dumpAsync, encode, encode, encode, encode, encodeMapKey, encodeMapKeys, encodeMapValue, encodeMapValues, get, getCodec, getIdleTime, getIdleTimeAsync, getLockByMapKey, getLockByValue, getName, getRawName, getRawName, isExists, migrate, migrateAsync, move, moveAsync, prefixName, removeListener, removeListenerAsync, removeListenersAsync, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, setName, sizeInMemory, 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, expireAt, expireAt, remainTimeToLive
-
Methods inherited from interface org.redisson.api.RExpirableAsync
expireAsync, expireAtAsync, expireAtAsync, remainTimeToLiveAsync
-
Methods inherited from interface org.redisson.api.RObject
addListener, copy, 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, copyAsync, dumpAsync, getIdleTimeAsync, migrateAsync, moveAsync, removeListenerAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, touchAsync, unlinkAsync
-
-
-
-
Constructor Detail
-
RedissonBloomFilter
protected RedissonBloomFilter(CommandAsyncExecutor commandExecutor, String name)
-
RedissonBloomFilter
protected RedissonBloomFilter(Codec codec, CommandAsyncExecutor commandExecutor, String name)
-
-
Method Detail
-
add
public boolean add(T object)
Description copied from interface:RBloomFilter
Adds element- Specified by:
add
in interfaceRBloomFilter<T>
- Parameters:
object
- - element to add- Returns:
true
if element has been added successfullyfalse
if element is already present
-
contains
public boolean contains(T object)
Description copied from interface:RBloomFilter
Check for element present- Specified by:
contains
in interfaceRBloomFilter<T>
- Parameters:
object
- - element- Returns:
true
if element is presentfalse
if element is not present
-
createBitSet
protected RBitSetAsync createBitSet(CommandBatchService executorService)
-
count
public long count()
Description copied from interface:RBloomFilter
Calculates probabilistic number of elements already added to Bloom filter.- Specified by:
count
in interfaceRBloomFilter<T>
- Returns:
- probabilistic number of elements
-
deleteAsync
public RFuture<Boolean> deleteAsync()
Description copied from interface:RObjectAsync
Delete object in async mode- Specified by:
deleteAsync
in interfaceRObjectAsync
- Overrides:
deleteAsync
in classRedissonObject
- Returns:
true
if object was deletedfalse
if not
-
sizeInMemoryAsync
public RFuture<Long> sizeInMemoryAsync()
Description copied from interface:RObjectAsync
Returns bytes amount used by object in Redis memory.- Specified by:
sizeInMemoryAsync
in interfaceRObjectAsync
- Overrides:
sizeInMemoryAsync
in classRedissonObject
- Returns:
- size in bytes
-
getMaxSize
protected long getMaxSize()
-
tryInit
public boolean tryInit(long expectedInsertions, double falseProbability)
Description copied from interface:RBloomFilter
Initializes Bloom filter params (size and hashIterations) calculated fromexpectedInsertions
andfalseProbability
Stores config to Redis server.- Specified by:
tryInit
in interfaceRBloomFilter<T>
- Parameters:
expectedInsertions
- - expected amount of insertions per elementfalseProbability
- - expected false probability- Returns:
true
if Bloom filter initializedfalse
if Bloom filter already has been initialized
-
expireAsync
public RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit)
Description copied from interface:RExpirableAsync
Set a timeout for object in async mode. After the timeout has expired, the key will automatically be deleted.- 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
-
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 interfaceRExpirableAsync
- Returns:
true
if the timeout was cleared andfalse
if not
-
getExpectedInsertions
public long getExpectedInsertions()
Description copied from interface:RBloomFilter
Returns expected amount of insertions per element. Calculated during bloom filter initialization.- Specified by:
getExpectedInsertions
in interfaceRBloomFilter<T>
- Returns:
- expected amount of insertions per element
-
getFalseProbability
public double getFalseProbability()
Description copied from interface:RBloomFilter
Returns false probability of element presence. Calculated during bloom filter initialization.- Specified by:
getFalseProbability
in interfaceRBloomFilter<T>
- Returns:
- false probability of element presence
-
getSize
public long getSize()
Description copied from interface:RBloomFilter
Returns number of bits in Redis memory required by this instance- Specified by:
getSize
in interfaceRBloomFilter<T>
- Returns:
- number of bits
-
getHashIterations
public int getHashIterations()
Description copied from interface:RBloomFilter
Returns hash iterations amount used per element. Calculated during bloom filter initialization.- Specified by:
getHashIterations
in interfaceRBloomFilter<T>
- Returns:
- hash iterations amount
-
isExistsAsync
public RFuture<Boolean> isExistsAsync()
Description copied from interface:RObjectAsync
Check object existence in async mode.- Specified by:
isExistsAsync
in interfaceRObjectAsync
- Overrides:
isExistsAsync
in classRedissonObject
- Returns:
true
if object exists andfalse
otherwise
-
renameAsync
public RFuture<Void> renameAsync(String newName)
Description copied from interface:RObjectAsync
Rename current object key tonewName
in async mode- Specified by:
renameAsync
in interfaceRObjectAsync
- Overrides:
renameAsync
in classRedissonObject
- Parameters:
newName
- - new name of object- Returns:
- void
-
renamenxAsync
public RFuture<Boolean> renamenxAsync(String newName)
Description copied from interface:RObjectAsync
Rename current object key tonewName
in async mode only if new key is not exists- Specified by:
renamenxAsync
in interfaceRObjectAsync
- Overrides:
renamenxAsync
in classRedissonObject
- Parameters:
newName
- - new name of object- Returns:
true
if object has been renamed successfully andfalse
otherwise
-
expire
public boolean expire(long timeToLive, TimeUnit timeUnit)
Description copied from interface:RExpirable
Set a timeout for object. After the timeout has expired, the key will automatically be deleted.- 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
-
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
public RFuture<Boolean> expireAtAsync(long timestamp)
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
public boolean expire(Instant instant)
Description copied from interface:RExpirable
Set an expire date for 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
-
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 interfaceRExpirableAsync
- Parameters:
instant
- - expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireAt
public boolean expireAt(Date timestamp)
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
public RFuture<Boolean> expireAtAsync(Date timestamp)
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
-
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
-
remainTimeToLive
public long remainTimeToLive()
Description copied from interface:RExpirable
Remaining time to live of Redisson object that has a timeout- 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
public RFuture<Long> remainTimeToLiveAsync()
Description copied from interface:RExpirableAsync
Remaining time to live of Redisson object that has a timeout- 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.
-
expireAsync
protected RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit, String... keys)
-
-