JdbcSandboxExecutionGuard
public final class JdbcSandboxExecutionGuard implements SandboxExecutionGuard
io/agentscope/extensions/mysql/sandbox/JdbcSandboxExecutionGuard.java:45–176JDBC 沙箱执行守卫,在多次调用之间保存和恢复会话与记忆数据。位于 io.agentscope.extensions.mysql.sandbox 包,实现 SandboxExecutionGuard。核心成员包括 builder、tryEnter。
JDBC-backed SandboxExecutionGuard using MySQL GET_LOCK() / RELEASE_LOCK().
Each lock is identified by a string key derived from the SandboxIsolationKey's scope
and value. GET_LOCK() blocks until the lock is available or the timeout expires.
The lock is tied to the database connection — when the connection closes, the lock is
automatically released.
The returned SandboxLease#close() calls RELEASE_LOCK() and closes the
underlying connection, ensuring the lock is freed even if the caller forgets to release it.
Important: MySQL named locks are server-scoped, not database-scoped. Use a unique
keyPrefix to avoid collisions with other applications sharing the same MySQL server.
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Builder | 类class | 构建器,用于构建并配置目标实例。 A class in io.agentscope.extensions.mysql.sandbox that persists and restores session and memory data across calls. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static Builder builder(DataSource dataSource)static | 返回构建器实例。 Performs the builder operation. |
public SandboxLease tryEnter(SandboxIsolationKey key) throws InterruptedException | 设置该参数。 Performs the try enter operation. |
方法详情Method Detail
builder
public static Builder builder(DataSource dataSource)
返回构建器实例。
Performs the builder operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
dataSource | DataSource | 数据来源(类型 `DataSource`)。The data source. |
Builderio/agentscope/extensions/mysql/sandbox/JdbcSandboxExecutionGuard.java:61–63tryEnter
public SandboxLease tryEnter(SandboxIsolationKey key) throws InterruptedException
设置该参数。
Performs the try enter operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | SandboxIsolationKey | 键(类型 `SandboxIsolationKey`)。The key. |
SandboxLeaseInterruptedException可能抛出 `InterruptedException`。Thrown when the operation cannot be completed.
io/agentscope/extensions/mysql/sandbox/JdbcSandboxExecutionGuard.java:65–97嵌套类详情Nested Class Detail
Builder
public static final class Builder构建器,用于构建并配置目标实例。位于 io.agentscope.extensions.mysql.sandbox 包。核心成员包括 keyPrefix、lockTimeout、build。
A class in io.agentscope.extensions.mysql.sandbox that persists and restores session and memory data across calls. Declared in io.agentscope.extensions.mysql.sandbox.