CosBaseStore
public class CosBaseStore implements BaseStore
源码Source
io/agentscope/extensions/cos/CosBaseStore.java:68–355COS 基类存储,负责持久化与读取数据。位于 io.agentscope.extensions.cos 包,实现 BaseStore。核心成员包括 builder、get、put、putIfVersion、search、delete。
Tencent Cloud COS backed BaseStore for the harness remote filesystem.
Items are stored as JSON objects in COS. The object key layout is:
{keyPrefix}{namespace[0]}/{namespace[1]}/.../{key}.json — item data
{keyPrefix}{namespace[0]}/{namespace[1]}/.../{key}.version — version counter
Usage:
`COSClient cosClient = new COSClient(cred, clientConfig);
BaseStore store = CosBaseStore.builder()
.cosClient(cosClient)
.bucketName("my-agentscope-bucket")
.keyPrefix("agentscope/store/")
.build();
HarnessAgent agent = HarnessAgent.builder()
.filesystem(new RemoteFilesystemSpec(store))
.build();
`
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Builder | 类class | 构建器,用于构建并配置目标实例。 A class in io.agentscope.extensions.cos that connects agents to messaging channels and enterprise platforms. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static Builder builder()static | 返回构建器实例。 Returns the builder. |
public StoreItem get(List<String> namespace, String key) | 按条件读取数据。 Performs the get operation. |
public void put(List<String> namespace, String key, Map<String, Object> value) | 执行 `put` 方法。 Performs the put operation. |
public boolean putIfVersion(List<String> namespace, String key, Map<String, Object> value, long expectedVersion) | 执行 `putIfVersion` 方法。 Performs the put if version operation. |
public List<StoreItem> search(List<String> namespace, int limit, int offset) | 执行搜索相关操作。 Performs the search operation. |
public void delete(List<String> namespace, String key) | 删除数据。 Performs the delete operation. |
方法详情Method Detail
builder
public static Builder builder()
static
返回构建器实例。
Returns the builder.
Builder返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source
io/agentscope/extensions/cos/CosBaseStore.java:87–89get
public StoreItem get(List<String> namespace, String key)
按条件读取数据。
Performs the get operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
namespace | List<String> | 命名空间(类型 `List`)。The namespace. |
key | String | 键(类型 `String`)。The key. |
StoreItem返回StoreItem。Returns store item.
源码Source
io/agentscope/extensions/cos/CosBaseStore.java:91–107put
public void put(List<String> namespace, String key, Map<String, Object> value)
执行 put 方法。
Performs the put operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
namespace | List<String> | 命名空间(类型 `List`)。The namespace. |
key | String | 键(类型 `String`)。The key. |
value | Map<String, Object> | 值(类型 `Map`)。The value. |
源码Source
io/agentscope/extensions/cos/CosBaseStore.java:109–121putIfVersion
public boolean putIfVersion(List<String> namespace, String key, Map<String, Object> value, long expectedVersion)
执行 putIfVersion 方法。
Performs the put if version operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
namespace | List<String> | 命名空间(类型 `List`)。The namespace. |
key | String | 键(类型 `String`)。The key. |
value | Map<String, Object> | 值(类型 `Map`)。The value. |
expectedVersion | long | expected 版本(类型 `long`)。The expected version. |
boolean返回布尔值,表示判断结果。Returns a boolean result.
源码Source
io/agentscope/extensions/cos/CosBaseStore.java:123–140search
public List<StoreItem> search(List<String> namespace, int limit, int offset)
执行搜索相关操作。
Performs the search operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
namespace | List<String> | 命名空间(类型 `List`)。The namespace. |
limit | int | 数量上限(类型 `int`)。The limit. |
offset | int | 偏移量(类型 `int`)。The offset. |
List<StoreItem>返回列出。Returns list.
源码Source
io/agentscope/extensions/cos/CosBaseStore.java:142–191delete
public void delete(List<String> namespace, String key)
删除数据。
Performs the delete operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
namespace | List<String> | 命名空间(类型 `List`)。The namespace. |
key | String | 键(类型 `String`)。The key. |
源码Source
io/agentscope/extensions/cos/CosBaseStore.java:193–205嵌套类详情Nested Class Detail
Builder
public static class Builder构建器,用于构建并配置目标实例。位于 io.agentscope.extensions.cos 包。核心成员包括 cosClient、bucketName、keyPrefix、build。
A class in io.agentscope.extensions.cos that connects agents to messaging channels and enterprise platforms. Declared in io.agentscope.extensions.cos.