RedisDistributedStore
public class RedisDistributedStore implements DistributedStore
io/agentscope/extensions/redis/RedisDistributedStore.java:56–109Redis 分布式存储,负责持久化与读取数据。位于 io.agentscope.extensions.redis 包,实现 DistributedStore。核心成员包括 fromJedis、agentStateStore、baseStore、sandboxSnapshotSpec、sandboxExecutionGuard。
Redis-backed DistributedStore that configures all distributed storage components
with a single Jedis connection.
Usage:
`JedisPooled jedis = new JedisPooled("redis://localhost:6379");
RedisDistributedStore store = RedisDistributedStore.fromJedis(jedis);
HarnessAgent agent = HarnessAgent.builder()
.name("my-agent")
.model("dashscope:qwen-plus")
.distributedStore(store)
.filesystem(new RemoteFilesystemSpec(store.baseStore())
.isolationScope(IsolationScope.USER))
.build();
`
This provides:
-
RedisAgentStateStore— agent session state (auto-wired by distributedStore) -
RedisStore— workspace filesystem KV (via#baseStore()) -
RedisSnapshotSpec— sandbox snapshot storage (auto-wired for sandbox mode) -
RedisSandboxExecutionGuard— sandbox concurrency lock (auto-wired for sandbox mode)
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static RedisDistributedStore fromJedis(UnifiedJedis jedis)static | 设置该参数。 Creates a Redis distributed store from a Jedis client with the default key prefix. |
public static RedisDistributedStore fromJedis(UnifiedJedis jedis, String keyPrefix)static | 执行 `fromJedis` 方法。 Creates a Redis distributed store from a Jedis client with a custom key prefix. |
public AgentStateStore agentStateStore() | 返回智能体状态存储。 Returns the agent state store. |
public BaseStore baseStore() | 返回基类存储。 Returns the base store. |
public SandboxSnapshotSpec sandboxSnapshotSpec() | 返回沙箱快照规格。 Returns the sandbox snapshot spec. |
public SandboxExecutionGuard sandboxExecutionGuard() | 返回沙箱执行守卫。 Returns the sandbox execution guard. |
方法详情Method Detail
fromJedis
public static RedisDistributedStore fromJedis(UnifiedJedis jedis)
设置该参数。
Creates a Redis distributed store from a Jedis client with the default key prefix.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
jedis | UnifiedJedis | jedis(类型 `UnifiedJedis`)。initialized Jedis client (e.g. `new JedisPooled("redis://localhost:6379")`) |
RedisDistributedStoreio/agentscope/extensions/redis/RedisDistributedStore.java:72–74fromJedis
public static RedisDistributedStore fromJedis(UnifiedJedis jedis, String keyPrefix)
执行 fromJedis 方法。
Creates a Redis distributed store from a Jedis client with a custom key prefix.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
jedis | UnifiedJedis | jedis(类型 `UnifiedJedis`)。initialized Jedis client |
keyPrefix | String | 键 Prefix(类型 `String`)。prefix for all Redis keys (e.g. `"myapp:"`) |
RedisDistributedStoreio/agentscope/extensions/redis/RedisDistributedStore.java:83–85agentStateStore
public AgentStateStore agentStateStore()
返回智能体状态存储。
Returns the agent state store.
AgentStateStoreio/agentscope/extensions/redis/RedisDistributedStore.java:87–93baseStore
public BaseStore baseStore()
返回基类存储。
Returns the base store.
BaseStoreio/agentscope/extensions/redis/RedisDistributedStore.java:95–98sandboxSnapshotSpec
public SandboxSnapshotSpec sandboxSnapshotSpec()
返回沙箱快照规格。
Returns the sandbox snapshot spec.
SandboxSnapshotSpecio/agentscope/extensions/redis/RedisDistributedStore.java:100–103sandboxExecutionGuard
public SandboxExecutionGuard sandboxExecutionGuard()
返回沙箱执行守卫。
Returns the sandbox execution guard.
SandboxExecutionGuardio/agentscope/extensions/redis/RedisDistributedStore.java:105–108