AS AgentScopeAPI 手册 / API Reference

JdbcAgentStateStore

public class JdbcAgentStateStore implements AgentStateStore
源码Source io/agentscope/extensions/jdbc/state/JdbcAgentStateStore.java:49–614

JDBC 智能体状态存储,负责持久化与读取数据。位于 io.agentscope.extensions.jdbc.state 包,实现 AgentStateStore。核心成员包括 save、supportsVersioning、getVersioned、saveIfVersion、get、getList。

Database-agnostic session state store backed by SessionStateDialect.

Implements AgentStateStore with zero inline SQL — every statement is sourced from the dialect via BoundSql.

构造器摘要Constructor Summary

构造器Constructor说明Description
public JdbcAgentStateStore(DataSource dataSource, SessionStateDialect dialect)
初始化 `JdbcAgentStateStore` 实例。
Creates a store with auto-schema creation disabled.
public JdbcAgentStateStore(DataSource dataSource, SessionStateDialect dialect, boolean createIfNotExist)
初始化 `JdbcAgentStateStore` 实例。
Creates a store with optional auto-schema creation.

方法摘要Method Summary

方法Method说明Description
public void save(String userId, String sessionId, String key, State value)
保存数据到持久化存储。
Saves a single value unconditionally.
public void save(String userId, String sessionId, String key, List<? extends State> values)
保存数据到持久化存储。
Performs the save operation.
public boolean supportsVersioning()
返回 `supportsVersioning` 结果。
Returns the supports versioning.
public T extends State VersionedState<T> getVersioned(String userId, String sessionId, String key, Class<T> type)
获取 `getVersioned`。
Returns the versioned.
public long saveIfVersion(String userId, String sessionId, String key, State value, long expectedVersion)
保存If 版本。
Writes and obtains the assigned version in one database transaction.
public T extends State Optional<T> get(String userId, String sessionId, String key, Class<T> type)
按条件读取数据。
Performs the get operation.
public T extends State List<T> getList(String userId, String sessionId, String key, Class<T> itemType)
获取列表。
Returns the list.
public boolean exists(String userId, String sessionId)
判断数据是否存在。
Performs the exists operation.
public void delete(String userId, String sessionId)
删除数据。
Performs the delete operation.
public Set<String> listSessionIds(String userId)
列出 `listSessionIds`。
Lists the session ids.

构造器详情Constructor Detail

JdbcAgentStateStore

public JdbcAgentStateStore(DataSource dataSource, SessionStateDialect dialect)

初始化 JdbcAgentStateStore 实例。

Creates a store with auto-schema creation disabled.

参数Parameters
名称Name类型Type说明Description
dataSourceDataSourceJDBC 数据来源。the JDBC data source
dialectSessionStateDialectdialect(类型 `SessionStateDialect`)。the session-state dialect
源码Source io/agentscope/extensions/jdbc/state/JdbcAgentStateStore.java:65–67

JdbcAgentStateStore

public JdbcAgentStateStore(DataSource dataSource, SessionStateDialect dialect, boolean createIfNotExist)

初始化 JdbcAgentStateStore 实例。

Creates a store with optional auto-schema creation.

参数Parameters
名称Name类型Type说明Description
dataSourceDataSourceJDBC 数据来源。the JDBC data source
dialectSessionStateDialectdialect(类型 `SessionStateDialect`)。the session-state dialect
createIfNotExistboolean创建 If 不 Exist(类型 `boolean`)。when true, auto-creates the sessions table
源码Source io/agentscope/extensions/jdbc/state/JdbcAgentStateStore.java:76–85

方法详情Method Detail

save

public void save(String userId, String sessionId, String key, State value)

保存数据到持久化存储。

Saves a single value unconditionally.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
keyString键(类型 `String`)。The key.
valueState值(类型 `State`)。The value.
源码Source io/agentscope/extensions/jdbc/state/JdbcAgentStateStore.java:129–144

save

public void save(String userId, String sessionId, String key, List<? extends State> values)

保存数据到持久化存储。

Performs the save operation.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
keyString键(类型 `String`)。The key.
valuesList<? extends State>值(类型 `List`)。The values.
源码Source io/agentscope/extensions/jdbc/state/JdbcAgentStateStore.java:146–197

supportsVersioning

public boolean supportsVersioning()

返回 supportsVersioning 结果。

Returns the supports versioning.

返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/extensions/jdbc/state/JdbcAgentStateStore.java:199–202

getVersioned

public T extends State VersionedState<T> getVersioned(String userId, String sessionId, String key, Class<T> type)

获取 getVersioned。

Returns the versioned.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
keyString键(类型 `String`)。The key.
typeClass<T>类型(类型 `Class`)。The type.
返回Returns VersionedState<T>
返回VersionedState。Returns versioned state.
源码Source io/agentscope/extensions/jdbc/state/JdbcAgentStateStore.java:204–226

saveIfVersion

public long saveIfVersion(String userId, String sessionId, String key, State value, long expectedVersion)

保存If 版本。

Writes and obtains the assigned version in one database transaction.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
keyString键(类型 `String`)。The key.
valueState值(类型 `State`)。The value.
expectedVersionlongexpected 版本(类型 `long`)。The expected version.
返回Returns long
返回数值结果。Returns a numeric result.
源码Source io/agentscope/extensions/jdbc/state/JdbcAgentStateStore.java:246–297

get

public T extends State Optional<T> get(String userId, String sessionId, String key, Class<T> type)

按条件读取数据。

Performs the get operation.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
keyString键(类型 `String`)。The key.
typeClass<T>类型(类型 `Class`)。The type.
返回Returns Optional<T>
返回可选。Returns optional.
源码Source io/agentscope/extensions/jdbc/state/JdbcAgentStateStore.java:320–341

getList

public T extends State List<T> getList(String userId, String sessionId, String key, Class<T> itemType)

获取列表。

Returns the list.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
keyString键(类型 `String`)。The key.
itemTypeClass<T>条目类型(类型 `Class`)。The item type.
返回Returns List<T>
返回列出。Returns list.
源码Source io/agentscope/extensions/jdbc/state/JdbcAgentStateStore.java:343–366

exists

public boolean exists(String userId, String sessionId)

判断数据是否存在。

Performs the exists operation.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/extensions/jdbc/state/JdbcAgentStateStore.java:368–383

delete

public void delete(String userId, String sessionId)

删除数据。

Performs the delete operation.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
源码Source io/agentscope/extensions/jdbc/state/JdbcAgentStateStore.java:385–403

listSessionIds

public Set<String> listSessionIds(String userId)

列出 listSessionIds。

Lists the session ids.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
返回Returns Set<String>
返回设置。Returns set.
源码Source io/agentscope/extensions/jdbc/state/JdbcAgentStateStore.java:405–428

继承成员Inherited Members

继承自Members inherited from AgentStateStore
基于官方固定版本源码静态生成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.