RedisClientWrapper
public class RedisClientWrapper implements AutoCloseable
io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:32–282Redis 客户端包装器,承载智能体的部署、调度与服务化运行。位于 io.agentscope.runtime.sandbox.map 包,实现 AutoCloseable。核心成员包括 set、get、delete、exists、keys、scan。
Redis Client wrapper for managing Redis connections and operations Uses Lettuce as the underlying Redis client
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public RedisClientWrapper(RedisManagerConfig config) | 初始化 `RedisClientWrapper` 实例。 Constructor with RedisManagerConfig |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public void set(String key, String value) | 执行设置相关操作。 Set a key-value pair |
public String get(String key) | 获取值通过密钥。 Get value by key |
public Long delete(String key) | 删除数据。 Delete a key |
public boolean exists(String key) | 判断数据是否存在。 Check if a key exists |
public List<String> keys(String pattern) | 设置密钥。 Get all keys matching a pattern |
public Set<String> scan(String pattern) | 设置该参数。 Scan keys matching a pattern |
public Long rpush(String key, String value) | 执行 `rpush` 方法。 Push value to the right end of a list |
public String lpop(String key) | 设置该参数。 Pop value from the left end of a list |
public String lindex(String key, long index) | 执行 `lindex` 方法。 Get element at index in a list |
public Long llen(String key) | 获取长度的列出。 Get the length of a list |
public List<String> lrange(String key, long start, long stop) | 执行 `lrange` 方法。 Get range of elements from a list |
public void ltrim(String key) | 设置该参数。 Remove all elements from a list |
public Long sadd(String key, String... members) | 执行 `sadd` 方法。 Add members to a set |
public Long srem(String key, String... members) | 执行 `srem` 方法。 Remove members from a set |
public boolean sismember(String key, String member) | 执行 `sismember` 方法。 Check if a member exists in a set |
public Set<String> smembers(String key) | 获取所有成员的设置。 Get all members of a set |
public Long scard(String key) | 获取大小的设置。 Get the size of a set |
public String ping() | 返回 `ping` 结果。 Ping the Redis server |
public RedisCommands<String, String> getSyncCommands() | 获取 `getSyncCommands`。 Get the underlying sync commands |
public void close() | 关闭连接并释放相关资源。 Close the Redis connection |
构造器详情Constructor Detail
RedisClientWrapper
public RedisClientWrapper(RedisManagerConfig config)
初始化 RedisClientWrapper 实例。
Constructor with RedisManagerConfig
| 名称Name | 类型Type | 说明Description |
|---|---|---|
config | RedisManagerConfig | 配置对象(类型 `RedisManagerConfig`)。Redis manager configuration |
io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:45–68方法详情Method Detail
set
public void set(String key, String value)
执行设置相关操作。
Set a key-value pair
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 密钥。the key |
value | String | 值(类型 `String`)。the value |
io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:76–78get
public String get(String key)
获取值通过密钥。
Get value by key
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 密钥。the key |
Stringio/agentscope/runtime/sandbox/map/RedisClientWrapper.java:86–88delete
public Long delete(String key)
删除数据。
Delete a key
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 密钥到删除。the key to delete |
Longio/agentscope/runtime/sandbox/map/RedisClientWrapper.java:96–98exists
public boolean exists(String key)
判断数据是否存在。
Check if a key exists
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 密钥到检查。the key to check |
booleanio/agentscope/runtime/sandbox/map/RedisClientWrapper.java:106–108keys
public List<String> keys(String pattern)
设置密钥。
Get all keys matching a pattern
| 名称Name | 类型Type | 说明Description |
|---|---|---|
pattern | String | pattern(类型 `String`)。the pattern to match |
List<String>io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:116–118scan
public Set<String> scan(String pattern)
设置该参数。
Scan keys matching a pattern
| 名称Name | 类型Type | 说明Description |
|---|---|---|
pattern | String | pattern(类型 `String`)。the pattern to match |
Set<String>io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:126–128rpush
public Long rpush(String key, String value)
执行 rpush 方法。
Push value to the right end of a list
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 列出密钥。the list key |
value | String | 值到推送。the value to push |
Longio/agentscope/runtime/sandbox/map/RedisClientWrapper.java:139–141lpop
public String lpop(String key)
设置该参数。
Pop value from the left end of a list
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 列出密钥。the list key |
Stringio/agentscope/runtime/sandbox/map/RedisClientWrapper.java:149–151lindex
public String lindex(String key, long index)
执行 lindex 方法。
Get element at index in a list
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 列出密钥。the list key |
index | long | 索引。the index |
Stringio/agentscope/runtime/sandbox/map/RedisClientWrapper.java:160–162llen
public Long llen(String key)
获取长度的列出。
Get the length of a list
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 列出密钥。the list key |
Longio/agentscope/runtime/sandbox/map/RedisClientWrapper.java:170–172lrange
public List<String> lrange(String key, long start, long stop)
执行 lrange 方法。
Get range of elements from a list
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 列出密钥。the list key |
start | long | 启动(类型 `long`)。start index |
stop | long | 停止(类型 `long`)。stop index |
List<String>io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:182–184ltrim
public void ltrim(String key)
设置该参数。
Remove all elements from a list
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 列出密钥。the list key |
io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:191–193sadd
public Long sadd(String key, String... members)
执行 sadd 方法。
Add members to a set
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 设置密钥。the set key |
members varargs | String... | 成员到添加。the members to add |
Longio/agentscope/runtime/sandbox/map/RedisClientWrapper.java:204–206srem
public Long srem(String key, String... members)
执行 srem 方法。
Remove members from a set
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 设置密钥。the set key |
members varargs | String... | 成员到移除。the members to remove |
Longio/agentscope/runtime/sandbox/map/RedisClientWrapper.java:215–217sismember
public boolean sismember(String key, String member)
执行 sismember 方法。
Check if a member exists in a set
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 设置密钥。the set key |
member | String | 成员到检查。the member to check |
booleanio/agentscope/runtime/sandbox/map/RedisClientWrapper.java:226–228smembers
public Set<String> smembers(String key)
获取所有成员的设置。
Get all members of a set
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 设置密钥。the set key |
Set<String>io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:236–238scard
public Long scard(String key)
获取大小的设置。
Get the size of a set
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 设置密钥。the set key |
Longio/agentscope/runtime/sandbox/map/RedisClientWrapper.java:246–248ping
public String ping()
返回 ping 结果。
Ping the Redis server
Stringio/agentscope/runtime/sandbox/map/RedisClientWrapper.java:255–257getSyncCommands
public RedisCommands<String, String> getSyncCommands()
获取 getSyncCommands。
Get the underlying sync commands
RedisCommands<String, String>io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:264–266close
public void close()
关闭连接并释放相关资源。
Close the Redis connection
io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:271–281