AS AgentScopeAPI 手册 / API Reference

SnapshotStore

public final class SnapshotStore
源码Source 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_CAPACITY
staticfinal
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
staticfinal

默认 CAPACITY字段。声明为 public static final int DEFAULT_CAPACITY。

Default per-session undo depth.

源码Source io/agentscope/spring/boot/admin/snapshot/SnapshotStore.java:37

构造器详情Constructor Detail

SnapshotStore

public SnapshotStore()

初始化 SnapshotStore 实例。

Creates a new instance.

源码Source io/agentscope/spring/boot/admin/snapshot/SnapshotStore.java:42–44

SnapshotStore

public SnapshotStore(int capacityPerSession)

初始化 SnapshotStore 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
capacityPerSessionintcapacity 每个会话(类型 `int`)。The capacity per session.
源码Source io/agentscope/spring/boot/admin/snapshot/SnapshotStore.java:46–48

方法详情Method Detail

push

public synchronized void push(String sessionId, String json)
synchronized

用于sessionId的推送新的快照。

Push a new snapshot for sessionId.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
jsonStringJSON(类型 `String`)。The json.
源码Source io/agentscope/spring/boot/admin/snapshot/SnapshotStore.java:51–59

undo

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.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
currentJsonString当前 JSON(类型 `String`)。The current json.
返回Returns Optional<String>
返回可选。the JSON of the snapshot to restore, or empty if none available
源码Source io/agentscope/spring/boot/admin/snapshot/SnapshotStore.java:67–80

redo

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.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
currentJsonString当前 JSON(类型 `String`)。The current json.
返回Returns Optional<String>
返回可选。Returns optional.
源码Source io/agentscope/spring/boot/admin/snapshot/SnapshotStore.java:86–99

undoDepth

public synchronized int undoDepth(String sessionId)
synchronized

设置该参数。

Performs the undo depth operation.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns int
返回数值结果。Returns a numeric result.
源码Source io/agentscope/spring/boot/admin/snapshot/SnapshotStore.java:101–104

redoDepth

public synchronized int redoDepth(String sessionId)
synchronized

设置该参数。

Performs the redo depth operation.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns int
返回数值结果。Returns a numeric result.
源码Source io/agentscope/spring/boot/admin/snapshot/SnapshotStore.java:106–109

clear

public synchronized void clear(String sessionId)
synchronized

清空或重置内部状态。

Clears or resets internal state.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
源码Source io/agentscope/spring/boot/admin/snapshot/SnapshotStore.java:111–113
基于官方固定版本源码静态生成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.