AS AgentScopeAPI 手册 / API Reference

RedisClientAdapter

public interface RedisClientAdapter
源码Source 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说明Description
public void set(String key, String value)
执行设置相关操作。
Set a string value.
public String get(String key)
按条件读取数据。
Get a string value.
public void rightPushList(String key, String value)
执行 `rightPushList` 方法。
Append a value to the right end of a list.
public List<String> rangeList(String key, long start, long end)
执行 `rangeList` 方法。
Get a range of elements from a list.
public long getListLength(String key)
获取长度的列出。
Get the length of a list.
public void deleteKeys(String... keys)
删除密钥。
Delete one or more keys.
public void addToSet(String key, String member)
添加到设置。
Add a member to a set.
public Set<String> getSetMembers(String key)
获取所有成员的设置。
Get all members of a set.
public long getSetSize(String key)
获取数量的成员 in 设置。
Get the number of members in a set.
public boolean keyExists(String key)
设置该参数。
Check if a key exists.
public Set<String> findKeysByPattern(String pattern)
查找 `findKeysByPattern`。
Find all keys matching a pattern.
public long evalScript(String script, List<String> keys, List<String> args)
执行 `evalScript` 方法。
Execute a Lua script atomically.
public void close()
关闭连接并释放相关资源。
Close the adapter and release resources.

方法详情Method Detail

set

public void set(String key, String value)

执行设置相关操作。

Set a string value.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。the Redis key
valueString值(类型 `String`)。the string value
源码Source io/agentscope/extensions/redis/state/RedisClientAdapter.java:44

get

public String get(String key)

按条件读取数据。

Get a string value.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。the Redis key
返回Returns String
返回字符串结果。the string value, or null if not found
源码Source io/agentscope/extensions/redis/state/RedisClientAdapter.java:52

rightPushList

public void rightPushList(String key, String value)

执行 rightPushList 方法。

Append a value to the right end of a list.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。the Redis list key
valueString值到追加。the value to append
源码Source io/agentscope/extensions/redis/state/RedisClientAdapter.java:60

rangeList

public List<String> rangeList(String key, long start, long end)

执行 rangeList 方法。

Get a range of elements from a list.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。the Redis list key
startlong启动(类型 `long`)。the start index (inclusive)
endlong结束(类型 `long`)。the end index (inclusive, -1 for all elements)
返回Returns List<String>
值的列出。list of values
源码Source io/agentscope/extensions/redis/state/RedisClientAdapter.java:70

getListLength

public long getListLength(String key)

获取长度的列出。

Get the length of a list.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。the Redis list key
返回Returns long
列出的长度。the length of the list
源码Source io/agentscope/extensions/redis/state/RedisClientAdapter.java:78

deleteKeys

public void deleteKeys(String... keys)

删除密钥。

Delete one or more keys.

参数Parameters
名称Name类型Type说明Description
keys varargsString...密钥到删除。the keys to delete
源码Source io/agentscope/extensions/redis/state/RedisClientAdapter.java:85

addToSet

public void addToSet(String key, String member)

添加到设置。

Add a member to a set.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。the Redis set key
memberString成员到添加。the member to add
源码Source io/agentscope/extensions/redis/state/RedisClientAdapter.java:93

getSetMembers

public Set<String> getSetMembers(String key)

获取所有成员的设置。

Get all members of a set.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。the Redis set key
返回Returns Set<String>
设置的成员。set of members
源码Source io/agentscope/extensions/redis/state/RedisClientAdapter.java:101

getSetSize

public long getSetSize(String key)

获取数量的成员 in 设置。

Get the number of members in a set.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。the Redis set key
返回Returns long
成员的数量。the number of members
源码Source io/agentscope/extensions/redis/state/RedisClientAdapter.java:109

keyExists

public boolean keyExists(String key)

设置该参数。

Check if a key exists.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。the Redis key
返回Returns boolean
返回布尔值,表示判断结果。true if the key exists
源码Source io/agentscope/extensions/redis/state/RedisClientAdapter.java:117

findKeysByPattern

public Set<String> findKeysByPattern(String pattern)

查找 findKeysByPattern。

Find all keys matching a pattern.

参数Parameters
名称Name类型Type说明Description
patternStringpattern(类型 `String`)。the key pattern (e.g., "prefix:*")
返回Returns Set<String>
返回设置。set of matching keys
源码Source io/agentscope/extensions/redis/state/RedisClientAdapter.java:125

evalScript

public long evalScript(String script, List<String> keys, List<String> args)

执行 evalScript 方法。

Execute a Lua script atomically.

参数Parameters
名称Name类型Type说明Description
scriptStringscript(类型 `String`)。the Lua script source
keysList<String>密钥(类型 `List`)。Redis keys passed as `KEYS`
argsList<String>参数(类型 `List`)。Redis arguments passed as `ARGV`
返回Returns long
返回数值结果。the script return value as a long
源码Source io/agentscope/extensions/redis/state/RedisClientAdapter.java:135

close

public void close()

关闭连接并释放相关资源。

Close the adapter and release resources.

源码Source io/agentscope/extensions/redis/state/RedisClientAdapter.java:140
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.