RedisClientAdapter
public interface RedisClientAdapter
io/agentscope/extensions/redis/state/RedisClientAdapter.java:36–141定义 Redis 客户端适配器契约的接口。位于 io.agentscope.extensions.redis.state 包。核心成员包括 set、get、rightPushList、rangeList、getListLength、deleteKeys。
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
方法详情Method Detail
set
public void set(String key, String value)
执行设置相关操作。
Set a string value.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 键(类型 `String`)。the Redis key |
value | String | 值(类型 `String`)。the string value |
io/agentscope/extensions/redis/state/RedisClientAdapter.java:44get
public String get(String key)
按条件读取数据。
Get a string value.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 键(类型 `String`)。the Redis key |
Stringio/agentscope/extensions/redis/state/RedisClientAdapter.java:52rightPushList
public void rightPushList(String key, String value)
执行 rightPushList 方法。
Append a value to the right end of a list.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 键(类型 `String`)。the Redis list key |
value | String | 值到追加。the value to append |
io/agentscope/extensions/redis/state/RedisClientAdapter.java:60rangeList
public List<String> rangeList(String key, long start, long end)
执行 rangeList 方法。
Get a range of elements from a list.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 键(类型 `String`)。the Redis list key |
start | long | 启动(类型 `long`)。the start index (inclusive) |
end | long | 结束(类型 `long`)。the end index (inclusive, -1 for all elements) |
List<String>io/agentscope/extensions/redis/state/RedisClientAdapter.java:70getListLength
public long getListLength(String key)
获取长度的列出。
Get the length of a list.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 键(类型 `String`)。the Redis list key |
longio/agentscope/extensions/redis/state/RedisClientAdapter.java:78deleteKeys
public void deleteKeys(String... keys)
删除密钥。
Delete one or more keys.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
keys varargs | String... | 密钥到删除。the keys to delete |
io/agentscope/extensions/redis/state/RedisClientAdapter.java:85addToSet
public void addToSet(String key, String member)
添加到设置。
Add a member to a set.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 键(类型 `String`)。the Redis set key |
member | String | 成员到添加。the member to add |
io/agentscope/extensions/redis/state/RedisClientAdapter.java:93getSetMembers
public Set<String> getSetMembers(String key)
获取所有成员的设置。
Get all members of a set.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 键(类型 `String`)。the Redis set key |
Set<String>io/agentscope/extensions/redis/state/RedisClientAdapter.java:101getSetSize
public long getSetSize(String key)
获取数量的成员 in 设置。
Get the number of members in a set.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 键(类型 `String`)。the Redis set key |
longio/agentscope/extensions/redis/state/RedisClientAdapter.java:109keyExists
public boolean keyExists(String key)
设置该参数。
Check if a key exists.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 键(类型 `String`)。the Redis key |
booleanio/agentscope/extensions/redis/state/RedisClientAdapter.java:117findKeysByPattern
public Set<String> findKeysByPattern(String pattern)
查找 findKeysByPattern。
Find all keys matching a pattern.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
pattern | String | pattern(类型 `String`)。the key pattern (e.g., "prefix:*") |
Set<String>io/agentscope/extensions/redis/state/RedisClientAdapter.java:125evalScript
public long evalScript(String script, List<String> keys, List<String> args)
执行 evalScript 方法。
Execute a Lua script atomically.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
script | String | script(类型 `String`)。the Lua script source |
keys | List<String> | 密钥(类型 `List`)。Redis keys passed as `KEYS` |
args | List<String> | 参数(类型 `List`)。Redis arguments passed as `ARGV` |
longio/agentscope/extensions/redis/state/RedisClientAdapter.java:135close
public void close()
关闭连接并释放相关资源。
Close the adapter and release resources.
io/agentscope/extensions/redis/state/RedisClientAdapter.java:140