Class SnapshotStore
java.lang.Object
io.agentscope.spring.boot.admin.snapshot.SnapshotStore
In-memory undo/redo stacks per session.
Stacks store the serialized JSON form of 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
FieldsModifier and TypeFieldDescriptionstatic final intDefault per-session undo depth. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidPush a new snapshot forsessionId.Pop the most recent redo snapshot, and pushcurrentJsononto the undo stack so a subsequentundo(String, String)can revert it.intPop the most recent undo snapshot, and atomically pushcurrentJsononto the redo stack so a subsequentredo(String, String)can restore it.int
-
Field Details
-
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITYDefault per-session undo depth.- See Also:
-
-
Constructor Details
-
SnapshotStore
public SnapshotStore() -
SnapshotStore
public SnapshotStore(int capacityPerSession)
-
-
Method Details
-
push
Push a new snapshot forsessionId. Clears the redo stack — this is a fresh edit. -
undo
Pop the most recent undo snapshot, and atomically pushcurrentJsononto the redo stack so a subsequentredo(String, String)can restore it.- Returns:
- the JSON of the snapshot to restore, or empty if none available
-
redo
Pop the most recent redo snapshot, and pushcurrentJsononto the undo stack so a subsequentundo(String, String)can revert it. -
undoDepth
-
redoDepth
-
clear
-