SessionStateDialect
public interface SessionStateDialect
io/agentscope/extensions/jdbc/dialect/table/SessionStateDialect.java:39–196定义会话状态 Dialect契约的接口。位于 io.agentscope.extensions.jdbc.dialect.table 包。核心成员包括 sessionStateTableName、sessionStateCreateTableDdls、sessionStateUpsert、sessionStateCheckTableExists、sessionStateInsert、sessionStateInsertIfAbsent。
Table-domain dialect interface for the session-state table.
Stores agent state keyed by (session_id, state_key, item_index).
Single states use item_index = 0; list states use one row per element.
Method names are prefixed with sessionState to avoid collision when
the aggregate class implements multiple table-domain interfaces.
Secondary index: the frequent WHERE session_id = ? and
session_id LIKE 'prefix%' queries require an index on session_id. Where
the database supports it (MySQL), vendors inline INDEX idx_session (session_id)
in the CREATE TABLE statement; the others append an idempotent
CREATE INDEX IF NOT EXISTS as a second element of the
#sessionStateCreateTableDdls() list.
方法摘要Method Summary
方法详情Method Detail
sessionStateTableName
default public String sessionStateTableName()
返回 sessionStateTableName 结果。
Base table name (without prefix).
Stringio/agentscope/extensions/jdbc/dialect/table/SessionStateDialect.java:42–44sessionStateCreateTableDdls
public List<String> sessionStateCreateTableDdls()
返回 sessionStateCreateTableDdls 结果。
DDL statements (one or more) to create the sessions table.
List<String>io/agentscope/extensions/jdbc/dialect/table/SessionStateDialect.java:51sessionStateUpsert
public BoundSql sessionStateUpsert(String sessionId, String stateKey, int itemIndex, String stateData)
执行 sessionStateUpsert 方法。
UPSERT a single state value.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
stateKey | String | 状态键(类型 `String`)。The state key. |
itemIndex | int | 条目索引(类型 `int`)。The item index. |
stateData | String | 状态数据(类型 `String`)。The state data. |
BoundSqlio/agentscope/extensions/jdbc/dialect/table/SessionStateDialect.java:54sessionStateCheckTableExists
public BoundSql sessionStateCheckTableExists(String tableName)
设置该参数。
Table-existence probe SQL.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
tableName | String | table 名称(类型 `String`)。The table name. |
BoundSqlio/agentscope/extensions/jdbc/dialect/table/SessionStateDialect.java:57sessionStateInsert
default public BoundSql sessionStateInsert(String sessionId, String stateKey, int itemIndex, String stateData)
执行会话状态插入相关操作。
INSERT for list items (one row per element).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
stateKey | String | 状态键(类型 `String`)。The state key. |
itemIndex | int | 条目索引(类型 `int`)。The item index. |
stateData | String | 状态数据(类型 `String`)。The state data. |
BoundSqlio/agentscope/extensions/jdbc/dialect/table/SessionStateDialect.java:64–74sessionStateInsertIfAbsent
default public BoundSql sessionStateInsertIfAbsent(String sessionId, String stateKey, int itemIndex, String stateData)
执行 sessionStateInsertIfAbsent 方法。
INSERT of a single state with version = 1.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
stateKey | String | 状态键(类型 `String`)。The state key. |
itemIndex | int | 条目索引(类型 `int`)。The item index. |
stateData | String | 状态数据(类型 `String`)。The state data. |
BoundSqlio/agentscope/extensions/jdbc/dialect/table/SessionStateDialect.java:83–94sessionStateUpdateIfVersion
default public BoundSql sessionStateUpdateIfVersion(String sessionId, String stateKey, int itemIndex, String stateData, long expectedVersion)
执行会话状态更新 If 版本相关操作。
Compare-and-swap UPDATE guarded by version == expectedVersion.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
stateKey | String | 状态键(类型 `String`)。The state key. |
itemIndex | int | 条目索引(类型 `int`)。The item index. |
stateData | String | 状态数据(类型 `String`)。The state data. |
expectedVersion | long | expected 版本(类型 `long`)。The expected version. |
BoundSqlio/agentscope/extensions/jdbc/dialect/table/SessionStateDialect.java:97–114sessionStateSelect
default public BoundSql sessionStateSelect(String sessionId, String stateKey, int itemIndex)
执行会话状态选择相关操作。
Single-state SELECT by item_index.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
stateKey | String | 状态键(类型 `String`)。The state key. |
itemIndex | int | 条目索引(类型 `int`)。The item index. |
BoundSqlio/agentscope/extensions/jdbc/dialect/table/SessionStateDialect.java:117–125sessionStateSelectVersioned
default public BoundSql sessionStateSelectVersioned(String sessionId, String stateKey, int itemIndex)
执行 sessionStateSelectVersioned 方法。
Single-state SELECT with optimistic-concurrency version.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
stateKey | String | 状态键(类型 `String`)。The state key. |
itemIndex | int | 条目索引(类型 `int`)。The item index. |
BoundSqlio/agentscope/extensions/jdbc/dialect/table/SessionStateDialect.java:128–136sessionStateSelectList
default public BoundSql sessionStateSelectList(String sessionId, String stateKey)
执行会话状态选择列表相关操作。
Ordered list SELECT.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
stateKey | String | 状态键(类型 `String`)。The state key. |
BoundSqlio/agentscope/extensions/jdbc/dialect/table/SessionStateDialect.java:139–146sessionStateDeleteByKey
default public BoundSql sessionStateDeleteByKey(String sessionId, String stateKey)
用于状态密钥的删除所有条目。
DELETE all items for a state key.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
stateKey | String | 状态键(类型 `String`)。The state key. |
BoundSqlio/agentscope/extensions/jdbc/dialect/table/SessionStateDialect.java:149–156sessionStateDeleteSession
default public BoundSql sessionStateDeleteSession(String sessionId)
设置会话状态删除会话。
DELETE an entire session.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
BoundSqlio/agentscope/extensions/jdbc/dialect/table/SessionStateDialect.java:159–162sessionStateSelectMaxIndex
default public BoundSql sessionStateSelectMaxIndex(String sessionId, String stateKey)
执行会话状态选择最大索引相关操作。
MAX(item_index) for change detection.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
stateKey | String | 状态键(类型 `String`)。The state key. |
BoundSqlio/agentscope/extensions/jdbc/dialect/table/SessionStateDialect.java:165–172sessionStateExists
default public BoundSql sessionStateExists(String sessionId)
设置该参数。
Session-existence probe.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
BoundSqlio/agentscope/extensions/jdbc/dialect/table/SessionStateDialect.java:175–179sessionStateListSessionIds
default public BoundSql sessionStateListSessionIds(String prefixPattern)
设置该参数。
List distinct session IDs matching a prefix pattern.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
prefixPattern | String | prefix Pattern(类型 `String`)。The prefix pattern. |
BoundSqlio/agentscope/extensions/jdbc/dialect/table/SessionStateDialect.java:182–190sessionStateLikeEscapeChar
default public char sessionStateLikeEscapeChar()
返回 sessionStateLikeEscapeChar 结果。
Escape character for LIKE patterns in #sessionStateListSessionIds.
chario/agentscope/extensions/jdbc/dialect/table/SessionStateDialect.java:193–195