AS AgentScopeAPI 手册 / API Reference

RedisClientWrapper

public class RedisClientWrapper implements AutoCloseable
源码Source io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:32–282

Redis 客户端包装器,承载智能体的部署、调度与服务化运行。位于 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

参数Parameters
名称Name类型Type说明Description
configRedisManagerConfig配置对象(类型 `RedisManagerConfig`)。Redis manager configuration
源码Source io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:45–68

方法详情Method Detail

set

public void set(String key, String value)

执行设置相关操作。

Set a key-value pair

参数Parameters
名称Name类型Type说明Description
keyString密钥。the key
valueString值(类型 `String`)。the value
源码Source io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:76–78

get

public String get(String key)

获取值通过密钥。

Get value by key

参数Parameters
名称Name类型Type说明Description
keyString密钥。the key
返回Returns String
返回字符串结果。the value, or null if key doesn't exist
源码Source io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:86–88

delete

public Long delete(String key)

删除数据。

Delete a key

参数Parameters
名称Name类型Type说明Description
keyString密钥到删除。the key to delete
返回Returns Long
返回数值结果。the number of keys that were removed
源码Source io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:96–98

exists

public boolean exists(String key)

判断数据是否存在。

Check if a key exists

参数Parameters
名称Name类型Type说明Description
keyString密钥到检查。the key to check
返回Returns boolean
返回布尔值,表示判断结果。true if key exists, false otherwise
源码Source io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:106–108

keys

public List<String> keys(String pattern)

设置密钥。

Get all keys matching a pattern

参数Parameters
名称Name类型Type说明Description
patternStringpattern(类型 `String`)。the pattern to match
返回Returns List<String>
返回列出。list of matching keys
源码Source io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:116–118

scan

public Set<String> scan(String pattern)

设置该参数。

Scan keys matching a pattern

参数Parameters
名称Name类型Type说明Description
patternStringpattern(类型 `String`)。the pattern to match
返回Returns Set<String>
返回设置。set of matching keys
源码Source io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:126–128

rpush

public Long rpush(String key, String value)

执行 rpush 方法。

Push value to the right end of a list

参数Parameters
名称Name类型Type说明Description
keyString列出密钥。the list key
valueString值到推送。the value to push
返回Returns Long
列出之后推送的长度。the length of the list after the push
源码Source io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:139–141

lpop

public String lpop(String key)

设置该参数。

Pop value from the left end of a list

参数Parameters
名称Name类型Type说明Description
keyString列出密钥。the list key
返回Returns String
返回字符串结果。the popped value, or null if list is empty
源码Source io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:149–151

lindex

public String lindex(String key, long index)

执行 lindex 方法。

Get element at index in a list

参数Parameters
名称Name类型Type说明Description
keyString列出密钥。the list key
indexlong索引。the index
返回Returns String
返回字符串结果。the element at index, or null
源码Source io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:160–162

llen

public Long llen(String key)

获取长度的列出。

Get the length of a list

参数Parameters
名称Name类型Type说明Description
keyString列出密钥。the list key
返回Returns Long
列出的长度。the length of the list
源码Source io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:170–172

lrange

public List<String> lrange(String key, long start, long stop)

执行 lrange 方法。

Get range of elements from a list

参数Parameters
名称Name类型Type说明Description
keyString列出密钥。the list key
startlong启动(类型 `long`)。start index
stoplong停止(类型 `long`)。stop index
返回Returns List<String>
返回列出。list of elements in the range
源码Source io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:182–184

ltrim

public void ltrim(String key)

设置该参数。

Remove all elements from a list

参数Parameters
名称Name类型Type说明Description
keyString列出密钥。the list key
源码Source io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:191–193

sadd

public Long sadd(String key, String... members)

执行 sadd 方法。

Add members to a set

参数Parameters
名称Name类型Type说明Description
keyString设置密钥。the set key
members varargsString...成员到添加。the members to add
返回Returns Long
成员已添加的数量。the number of members added
源码Source io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:204–206

srem

public Long srem(String key, String... members)

执行 srem 方法。

Remove members from a set

参数Parameters
名称Name类型Type说明Description
keyString设置密钥。the set key
members varargsString...成员到移除。the members to remove
返回Returns Long
成员已移除的数量。the number of members removed
源码Source io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:215–217

sismember

public boolean sismember(String key, String member)

执行 sismember 方法。

Check if a member exists in a set

参数Parameters
名称Name类型Type说明Description
keyString设置密钥。the set key
memberString成员到检查。the member to check
返回Returns boolean
返回布尔值,表示判断结果。true if member exists, false otherwise
源码Source io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:226–228

smembers

public Set<String> smembers(String key)

获取所有成员的设置。

Get all members of a set

参数Parameters
名称Name类型Type说明Description
keyString设置密钥。the set key
返回Returns Set<String>
设置的所有成员。set of all members
源码Source io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:236–238

scard

public Long scard(String key)

获取大小的设置。

Get the size of a set

参数Parameters
名称Name类型Type说明Description
keyString设置密钥。the set key
返回Returns Long
设置的大小。the size of the set
源码Source io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:246–248

ping

public String ping()

返回 ping 结果。

Ping the Redis server

返回Returns String
返回字符串结果。"PONG" if successful
源码Source io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:255–257

getSyncCommands

public RedisCommands<String, String> getSyncCommands()

获取 getSyncCommands。

Get the underlying sync commands

返回Returns RedisCommands<String, String>
返回RedisCommands。Redis sync commands
源码Source io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:264–266

close

public void close()

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

Close the Redis connection

源码Source io/agentscope/runtime/sandbox/map/RedisClientWrapper.java:271–281
基于官方固定版本源码静态生成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.