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 protectedRedissonBloomFilter(Codec codec, CommandAsyncExecutor commandExecutor, String name)protectedRedissonBloomFilter(CommandAsyncExecutor commandExecutor, String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(T object)Adds elementbooleanclearExpire()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)booleancontains(T object)Check for element presentlongcount()Calculates probabilistic number of elements already added to Bloom filter.protected RBitSetAsynccreateBitSet(CommandBatchService executorService)RFuture<Boolean>deleteAsync()Delete object in async modebooleanexpire(long timeToLive, TimeUnit timeUnit)Set a timeout for object.booleanexpire(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.booleanexpireAt(long timestamp)UseRExpirable.expire(Instant)insteadbooleanexpireAt(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)insteadlonggetExpectedInsertions()Returns expected amount of insertions per element.doublegetFalseProbability()Returns false probability of element presence.intgetHashIterations()Returns hash iterations amount used per element.protected longgetMaxSize()longgetSize()Returns number of bits in Redis memory required by this instanceRFuture<Boolean>isExistsAsync()Check object existence in async mode.longremainTimeToLive()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 tonewNamein async modeRFuture<Boolean>renamenxAsync(String newName)Rename current object key tonewNamein async mode only if new key is not existsRFuture<Long>sizeInMemoryAsync()Returns bytes amount used by object in Redis memory.booleantryInit(long expectedInsertions, double falseProbability)Initializes Bloom filter params (size and hashIterations) calculated fromexpectedInsertionsandfalseProbabilityStores 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:RBloomFilterAdds element- Specified by:
addin interfaceRBloomFilter<T>- Parameters:
object- - element to add- Returns:
trueif element has been added successfullyfalseif element is already present
-
contains
public boolean contains(T object)
Description copied from interface:RBloomFilterCheck for element present- Specified by:
containsin interfaceRBloomFilter<T>- Parameters:
object- - element- Returns:
trueif element is presentfalseif element is not present
-
createBitSet
protected RBitSetAsync createBitSet(CommandBatchService executorService)
-
count
public long count()
Description copied from interface:RBloomFilterCalculates probabilistic number of elements already added to Bloom filter.- Specified by:
countin interfaceRBloomFilter<T>- Returns:
- probabilistic number of elements
-
deleteAsync
public RFuture<Boolean> deleteAsync()
Description copied from interface:RObjectAsyncDelete object in async mode- Specified by:
deleteAsyncin interfaceRObjectAsync- Overrides:
deleteAsyncin classRedissonObject- Returns:
trueif object was deletedfalseif not
-
sizeInMemoryAsync
public RFuture<Long> sizeInMemoryAsync()
Description copied from interface:RObjectAsyncReturns bytes amount used by object in Redis memory.- Specified by:
sizeInMemoryAsyncin interfaceRObjectAsync- Overrides:
sizeInMemoryAsyncin classRedissonObject- Returns:
- size in bytes
-
getMaxSize
protected long getMaxSize()
-
tryInit
public boolean tryInit(long expectedInsertions, double falseProbability)Description copied from interface:RBloomFilterInitializes Bloom filter params (size and hashIterations) calculated fromexpectedInsertionsandfalseProbabilityStores config to Redis server.- Specified by:
tryInitin interfaceRBloomFilter<T>- Parameters:
expectedInsertions- - expected amount of insertions per elementfalseProbability- - expected false probability- Returns:
trueif Bloom filter initializedfalseif Bloom filter already has been initialized
-
expireAsync
public RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit)
Description copied from interface:RExpirableAsyncSet a timeout for object in async mode. After the timeout has expired, the key will automatically be deleted.- Specified by:
expireAsyncin interfaceRExpirableAsync- Parameters:
timeToLive- - timeout before object will be deletedtimeUnit- - timeout time unit- Returns:
trueif the timeout was set andfalseif not
-
clearExpireAsync
public RFuture<Boolean> clearExpireAsync()
Description copied from interface:RExpirableAsyncClear an expire timeout or expire date for object in async mode. Object will not be deleted.- Specified by:
clearExpireAsyncin interfaceRExpirableAsync- Returns:
trueif the timeout was cleared andfalseif not
-
getExpectedInsertions
public long getExpectedInsertions()
Description copied from interface:RBloomFilterReturns expected amount of insertions per element. Calculated during bloom filter initialization.- Specified by:
getExpectedInsertionsin interfaceRBloomFilter<T>- Returns:
- expected amount of insertions per element
-
getFalseProbability
public double getFalseProbability()
Description copied from interface:RBloomFilterReturns false probability of element presence. Calculated during bloom filter initialization.- Specified by:
getFalseProbabilityin interfaceRBloomFilter<T>- Returns:
- false probability of element presence
-
getSize
public long getSize()
Description copied from interface:RBloomFilterReturns number of bits in Redis memory required by this instance- Specified by:
getSizein interfaceRBloomFilter<T>- Returns:
- number of bits
-
getHashIterations
public int getHashIterations()
Description copied from interface:RBloomFilterReturns hash iterations amount used per element. Calculated during bloom filter initialization.- Specified by:
getHashIterationsin interfaceRBloomFilter<T>- Returns:
- hash iterations amount
-
isExistsAsync
public RFuture<Boolean> isExistsAsync()
Description copied from interface:RObjectAsyncCheck object existence in async mode.- Specified by:
isExistsAsyncin interfaceRObjectAsync- Overrides:
isExistsAsyncin classRedissonObject- Returns:
trueif object exists andfalseotherwise
-
renameAsync
public RFuture<Void> renameAsync(String newName)
Description copied from interface:RObjectAsyncRename current object key tonewNamein async mode- Specified by:
renameAsyncin interfaceRObjectAsync- Overrides:
renameAsyncin classRedissonObject- Parameters:
newName- - new name of object- Returns:
- void
-
renamenxAsync
public RFuture<Boolean> renamenxAsync(String newName)
Description copied from interface:RObjectAsyncRename current object key tonewNamein async mode only if new key is not exists- Specified by:
renamenxAsyncin interfaceRObjectAsync- Overrides:
renamenxAsyncin classRedissonObject- Parameters:
newName- - new name of object- Returns:
trueif object has been renamed successfully andfalseotherwise
-
expire
public boolean expire(long timeToLive, TimeUnit timeUnit)Description copied from interface:RExpirableSet a timeout for object. After the timeout has expired, the key will automatically be deleted.- Specified by:
expirein interfaceRExpirable- Parameters:
timeToLive- - timeout before object will be deletedtimeUnit- - timeout time unit- Returns:
trueif the timeout was set andfalseif not
-
expireAt
public boolean expireAt(long timestamp)
Description copied from interface:RExpirableUseRExpirable.expire(Instant)instead- Specified by:
expireAtin interfaceRExpirable- Parameters:
timestamp- - expire date in milliseconds (Unix timestamp)- Returns:
trueif the timeout was set andfalseif not
-
expireAtAsync
public RFuture<Boolean> expireAtAsync(long timestamp)
Description copied from interface:RExpirableAsyncUseRExpirableAsync.expireAsync(Instant)instead- Specified by:
expireAtAsyncin interfaceRExpirableAsync- Parameters:
timestamp- - expire date in milliseconds (Unix timestamp)- Returns:
trueif the timeout was set andfalseif not
-
expire
public boolean expire(Instant instant)
Description copied from interface:RExpirableSet an expire date for object. When expire date comes the key will automatically be deleted.- Specified by:
expirein interfaceRExpirable- Parameters:
instant- - expire date- Returns:
trueif the timeout was set andfalseif not
-
expireAsync
public RFuture<Boolean> expireAsync(Instant instant)
Description copied from interface:RExpirableAsyncSet an expire date for object. When expire date comes the key will automatically be deleted.- Specified by:
expireAsyncin interfaceRExpirableAsync- Parameters:
instant- - expire date- Returns:
trueif the timeout was set andfalseif not
-
expireAt
public boolean expireAt(Date timestamp)
Description copied from interface:RExpirableUseRExpirable.expire(Instant)instead- Specified by:
expireAtin interfaceRExpirable- Parameters:
timestamp- - expire date- Returns:
trueif the timeout was set andfalseif not
-
expireAtAsync
public RFuture<Boolean> expireAtAsync(Date timestamp)
Description copied from interface:RExpirableAsyncUseRExpirableAsync.expireAsync(Instant)instead- Specified by:
expireAtAsyncin interfaceRExpirableAsync- Parameters:
timestamp- - expire date- Returns:
trueif the timeout was set andfalseif not
-
clearExpire
public boolean clearExpire()
Description copied from interface:RExpirableClear an expire timeout or expire date for object.- Specified by:
clearExpirein interfaceRExpirable- Returns:
trueif timeout was removedfalseif object does not exist or does not have an associated timeout
-
remainTimeToLive
public long remainTimeToLive()
Description copied from interface:RExpirableRemaining time to live of Redisson object that has a timeout- Specified by:
remainTimeToLivein 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:RExpirableAsyncRemaining time to live of Redisson object that has a timeout- Specified by:
remainTimeToLiveAsyncin 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)
-
-