AS AgentScopeAPI 手册 / API Reference

JdbcSandboxExecutionGuard

public final class JdbcSandboxExecutionGuard implements SandboxExecutionGuard
源码Source io/agentscope/extensions/mysql/sandbox/JdbcSandboxExecutionGuard.java:45–176

JDBC 沙箱执行守卫,在多次调用之间保存和恢复会话与记忆数据。位于 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)
static

返回构建器实例。

Performs the builder operation.

参数Parameters
名称Name类型Type说明Description
dataSourceDataSource数据来源(类型 `DataSource`)。The data source.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/mysql/sandbox/JdbcSandboxExecutionGuard.java:61–63

tryEnter

public SandboxLease tryEnter(SandboxIsolationKey key) throws InterruptedException

设置该参数。

Performs the try enter operation.

参数Parameters
名称Name类型Type说明Description
keySandboxIsolationKey键(类型 `SandboxIsolationKey`)。The key.
返回Returns SandboxLease
返回SandboxLease。Returns sandbox lease.
抛出Throws
  • InterruptedException 可能抛出 `InterruptedException`。Thrown when the operation cannot be completed.
源码Source 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.

继承成员Inherited Members

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