Interface RedisClientAdapter
- All Known Implementing Classes:
JedisClientAdapter,LettuceClientAdapter,RedissonClientAdapter
public interface RedisClientAdapter
Adapter interface for Redis client operations.
This interface provides a unified abstraction over different Redis client implementations (Jedis, Lettuce, Redisson), allowing the RedisAgentStateStore to work with any of them without modification.
All method names are designed to be self-explanatory and follow a consistent naming pattern:
- String operations:
set,get - List operations:
rightPushList,rangeList,getListLength - Set operations:
addToSet,getSetMembers,getSetSize - Key operations:
keyExists,deleteKeys,findKeysByPattern
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a member to a set.voidclose()Close the adapter and release resources.voiddeleteKeys(String... keys) Delete one or more keys.longExecute a Lua script atomically.findKeysByPattern(String pattern) Find all keys matching a pattern.Get a string value.longgetListLength(String key) Get the length of a list.getSetMembers(String key) Get all members of a set.longgetSetSize(String key) Get the number of members in a set.booleanCheck if a key exists.Get a range of elements from a list.voidrightPushList(String key, String value) Append a value to the right end of a list.voidSet a string value.
-
Method Details
-
set
Set a string value.- Parameters:
key- the Redis keyvalue- the string value
-
get
Get a string value.- Parameters:
key- the Redis key- Returns:
- the string value, or null if not found
-
rightPushList
Append a value to the right end of a list.- Parameters:
key- the Redis list keyvalue- the value to append
-
rangeList
Get a range of elements from a list.- Parameters:
key- the Redis list keystart- the start index (inclusive)end- the end index (inclusive, -1 for all elements)- Returns:
- list of values
-
getListLength
Get the length of a list.- Parameters:
key- the Redis list key- Returns:
- the length of the list
-
deleteKeys
Delete one or more keys.- Parameters:
keys- the keys to delete
-
addToSet
Add a member to a set.- Parameters:
key- the Redis set keymember- the member to add
-
getSetMembers
Get all members of a set.- Parameters:
key- the Redis set key- Returns:
- set of members
-
getSetSize
Get the number of members in a set.- Parameters:
key- the Redis set key- Returns:
- the number of members
-
keyExists
Check if a key exists.- Parameters:
key- the Redis key- Returns:
- true if the key exists
-
findKeysByPattern
Find all keys matching a pattern.- Parameters:
pattern- the key pattern (e.g., "prefix:*")- Returns:
- set of matching keys
-
evalScript
Execute a Lua script atomically.- Parameters:
script- the Lua script sourcekeys- Redis keys passed asKEYSargs- Redis arguments passed asARGV- Returns:
- the script return value as a long
-
close
void close()Close the adapter and release resources.
-