SnapshotStore
public final class SnapshotStore
io/agentscope/spring/boot/admin/snapshot/SnapshotStore.java:34–119快照存储,负责持久化与读取数据。位于 io.agentscope.spring.boot.admin.snapshot 包。核心成员包括 push、undo、redo、undoDepth、redoDepth、clear。
In-memory undo/redo stacks per session.
Stacks store the serialized JSON form of io.agentscope.core.state.AgentState —
deserialization happens at restore time. A bounded per-session capacity (default 20) caps
memory use; the oldest snapshot is dropped when the limit is hit.
This is a deliberately simple, single-node store. Cluster-aware deployments should swap in
a Redis-backed implementation by exposing a custom SnapshotStore bean.
字段摘要Field Summary
| 字段Field | 类型Type | 说明Description |
|---|---|---|
DEFAULT_CAPACITYstaticfinal | int | 默认 CAPACITY字段。 Default per-session undo depth. |
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public SnapshotStore() | 初始化 `SnapshotStore` 实例。 Creates a new instance. |
public SnapshotStore(int capacityPerSession) | 初始化 `SnapshotStore` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public synchronized void push(String sessionId, String json)synchronized | 用于`sessionId`的推送新的快照。 Push a new snapshot for `sessionId`. |
public synchronized Optional<String> undo(String sessionId, String currentJson)synchronized | 执行 `undo` 方法。 Pop the most recent undo snapshot, and atomically push `currentJson` onto the redo
stack so a subsequent `#redo(String, String)` can restore it. |
public synchronized Optional<String> redo(String sessionId, String currentJson)synchronized | 执行 `redo` 方法。 Pop the most recent redo snapshot, and push `currentJson` onto the undo stack so a
subsequent `#undo(String, String)` can revert it. |
public synchronized int undoDepth(String sessionId)synchronized | 设置该参数。 Performs the undo depth operation. |
public synchronized int redoDepth(String sessionId)synchronized | 设置该参数。 Performs the redo depth operation. |
public synchronized void clear(String sessionId)synchronized | 清空或重置内部状态。 Clears or resets internal state. |
字段详情Field Detail
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITY
默认 CAPACITY字段。声明为 public static final int DEFAULT_CAPACITY。
Default per-session undo depth.
io/agentscope/spring/boot/admin/snapshot/SnapshotStore.java:37构造器详情Constructor Detail
SnapshotStore
public SnapshotStore()
初始化 SnapshotStore 实例。
Creates a new instance.
io/agentscope/spring/boot/admin/snapshot/SnapshotStore.java:42–44SnapshotStore
public SnapshotStore(int capacityPerSession)
初始化 SnapshotStore 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
capacityPerSession | int | capacity 每个会话(类型 `int`)。The capacity per session. |
io/agentscope/spring/boot/admin/snapshot/SnapshotStore.java:46–48方法详情Method Detail
push
public synchronized void push(String sessionId, String json)
用于sessionId的推送新的快照。
Push a new snapshot for sessionId.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
json | String | JSON(类型 `String`)。The json. |
io/agentscope/spring/boot/admin/snapshot/SnapshotStore.java:51–59undo
public synchronized Optional<String> undo(String sessionId, String currentJson)
执行 undo 方法。
Pop the most recent undo snapshot, and atomically push currentJson onto the redo stack so a subsequent #redo(String, String) can restore it.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
currentJson | String | 当前 JSON(类型 `String`)。The current json. |
Optional<String>io/agentscope/spring/boot/admin/snapshot/SnapshotStore.java:67–80redo
public synchronized Optional<String> redo(String sessionId, String currentJson)
执行 redo 方法。
Pop the most recent redo snapshot, and push currentJson onto the undo stack so a subsequent #undo(String, String) can revert it.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
currentJson | String | 当前 JSON(类型 `String`)。The current json. |
Optional<String>io/agentscope/spring/boot/admin/snapshot/SnapshotStore.java:86–99undoDepth
public synchronized int undoDepth(String sessionId)
设置该参数。
Performs the undo depth operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
intio/agentscope/spring/boot/admin/snapshot/SnapshotStore.java:101–104redoDepth
public synchronized int redoDepth(String sessionId)
设置该参数。
Performs the redo depth operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
intio/agentscope/spring/boot/admin/snapshot/SnapshotStore.java:106–109clear
public synchronized void clear(String sessionId)
清空或重置内部状态。
Clears or resets internal state.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
io/agentscope/spring/boot/admin/snapshot/SnapshotStore.java:111–113