InMemoryStore
public class InMemoryStore implements BaseStore
io/agentscope/harness/agent/filesystem/remote/store/InMemoryStore.java:34–121In 记忆存储,负责持久化与读取数据。位于 io.agentscope.harness.agent.filesystem.remote.store 包,实现 BaseStore。核心成员包括 get、put、putIfVersion、search、delete、size。
Thread-safe in-memory implementation of BaseStore.
Items are stored in a ConcurrentHashMap keyed by the concatenation of
namespace components and the item key, separated by '\0'.
Every successful #put and #putIfVersion increments the item's
StoreItem#version() counter, enabling optimistic concurrency control.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
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` 方法。 Atomic compare-and-swap: updates the item only when the stored version equals
`expectedVersion`. |
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. |
public int size() | 返回大小。 Returns the number of items currently stored. |
public void clear() | 清空或重置内部状态。 Removes all items from the store. |
方法详情Method Detail
get
public StoreItem get(List<String> namespace, String key)
按条件读取数据。
Performs the get operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
namespace | List<String> | 命名空间(类型 `List`)。The namespace. |
key | String | 键(类型 `String`)。The key. |
StoreItemio/agentscope/harness/agent/filesystem/remote/store/InMemoryStore.java:38–41put
public void put(List<String> namespace, String key, Map<String, Object> value)
执行 put 方法。
Performs the put operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
namespace | List<String> | 命名空间(类型 `List`)。The namespace. |
key | String | 键(类型 `String`)。The key. |
value | Map<String, Object> | 值(类型 `Map`)。The value. |
io/agentscope/harness/agent/filesystem/remote/store/InMemoryStore.java:43–52putIfVersion
public boolean putIfVersion(List<String> namespace, String key, Map<String, Object> value, long expectedVersion)
执行 putIfVersion 方法。
Atomic compare-and-swap: updates the item only when the stored version equals expectedVersion.
| 名称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. |
booleanio/agentscope/harness/agent/filesystem/remote/store/InMemoryStore.java:61–77search
public List<StoreItem> search(List<String> namespace, int limit, int offset)
执行搜索相关操作。
Performs the search operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
namespace | List<String> | 命名空间(类型 `List`)。The namespace. |
limit | int | 数量上限(类型 `int`)。The limit. |
offset | int | 偏移量(类型 `int`)。The offset. |
List<StoreItem>io/agentscope/harness/agent/filesystem/remote/store/InMemoryStore.java:79–93delete
public void delete(List<String> namespace, String key)
删除数据。
Performs the delete operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
namespace | List<String> | 命名空间(类型 `List`)。The namespace. |
key | String | 键(类型 `String`)。The key. |
io/agentscope/harness/agent/filesystem/remote/store/InMemoryStore.java:95–98size
public int size()
返回大小。
Returns the number of items currently stored.
intio/agentscope/harness/agent/filesystem/remote/store/InMemoryStore.java:101–103clear
public void clear()
清空或重置内部状态。
Removes all items from the store.
io/agentscope/harness/agent/filesystem/remote/store/InMemoryStore.java:106–108