Class JedisRedisOperations
java.lang.Object
io.github.ravocode.avoonce.redis.JedisRedisOperations
- All Implemented Interfaces:
RedisOperations
A
RedisOperations adapter for the Jedis client.-
Constructor Summary
ConstructorsConstructorDescriptionJedisRedisOperations(redis.clients.jedis.JedisPool jedisPool) Constructs aJedisRedisOperationsinstance using the givenJedisPool. -
Method Summary
Modifier and TypeMethodDescriptionvoiddelete(byte[] key) Deletes the specified key.byte[]get(byte[] key) Retrieves the value associated with a key.voidset(byte[] key, byte[] value, long ttlMillis) Updates an existing key with a new value and extends its time-to-live.booleansetIfAbsent(byte[] key, byte[] value, long ttlMillis) Atomically sets a key to a value with a time-to-live only if the key does not already exist.
-
Constructor Details
-
JedisRedisOperations
public JedisRedisOperations(redis.clients.jedis.JedisPool jedisPool) Constructs aJedisRedisOperationsinstance using the givenJedisPool.- Parameters:
jedisPool- the Jedis connection pool.
-
-
Method Details
-
setIfAbsent
public boolean setIfAbsent(byte[] key, byte[] value, long ttlMillis) Atomically sets a key to a value with a time-to-live only if the key does not already exist. Equivalent to Redis command:SET key value NX PX ttlMillis- Specified by:
setIfAbsentin interfaceRedisOperations- Parameters:
key- The key to set.value- The value to store.ttlMillis- Time-to-live in milliseconds.- Returns:
trueif the key was set,falseif it already existed.
-
set
public void set(byte[] key, byte[] value, long ttlMillis) Updates an existing key with a new value and extends its time-to-live. Equivalent to Redis command:SET key value XX PX ttlMillis- Specified by:
setin interfaceRedisOperations- Parameters:
key- The key to update.value- The new value to store.ttlMillis- Time-to-live in milliseconds.
-
get
public byte[] get(byte[] key) Retrieves the value associated with a key. Equivalent to Redis command:GET key- Specified by:
getin interfaceRedisOperations- Parameters:
key- The key to retrieve.- Returns:
- The value, or
nullif the key does not exist.
-
delete
public void delete(byte[] key) Deletes the specified key. Equivalent to Redis command:DEL key- Specified by:
deletein interfaceRedisOperations- Parameters:
key- The key to delete.
-