Interface RedisOperations
- All Known Implementing Classes:
JedisRedisOperations, LettuceRedisOperations
public interface RedisOperations
Service Provider Interface for basic Redis operations.
Allows decoupling AvoOnce from any specific Redis client (e.g. Jedis, Lettuce).
-
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.
-
Method Details
-
setIfAbsent
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- 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
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- Parameters:
key- The key to update.value- The new value to store.ttlMillis- Time-to-live in milliseconds.
-
get
byte[] get(byte[] key) Retrieves the value associated with a key. Equivalent to Redis command:GET key- Parameters:
key- The key to retrieve.- Returns:
- The value, or
nullif the key does not exist.
-
delete
void delete(byte[] key) Deletes the specified key. Equivalent to Redis command:DEL key- Parameters:
key- The key to delete.
-