Class PostgresBaseStore
- All Implemented Interfaces:
io.agentscope.harness.agent.filesystem.remote.store.BaseStore
BaseStore.
Schema
CREATE TABLE agentscope_store (
namespace_path VARCHAR(2048) NOT NULL,
item_key VARCHAR(255) NOT NULL,
value_json TEXT NOT NULL,
version BIGINT NOT NULL,
updated_at BIGINT NOT NULL,
PRIMARY KEY (namespace_path, item_key)
)
The optional Builder#initializeSchema(true) flag runs
CREATE TABLE IF NOT EXISTS on construction.
Namespace encoding
To preserve the prefix-search behaviour of InMemoryStore,
the namespace components are joined with the ASCII unit-separator 0x1F and stored with a
trailing separator. Searching by namespace [a, b] translates into
WHERE namespace_path LIKE 'ab%' ESCAPE '!', which matches both that exact
namespace and any deeper sub-namespace. Namespace segments that contain 0x1F are
rejected.
CAS
putIfVersion(java.util.List<java.lang.String>, java.lang.String, java.util.Map<java.lang.String, java.lang.Object>, long) uses a single-statement conditional UPDATE keyed on
version. The expectedVersion == 0 case issues an INSERT and treats a
primary-key conflict as a failed CAS. Both paths are atomic without additional locking, so the
store is safe to share among multiple JVMs writing to the same database.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault table name used when the builder is not customised. -
Method Summary
Modifier and TypeMethodDescriptionstatic PostgresBaseStore.Builderbuilder(DataSource dataSource) Creates a builder forPostgresBaseStore.voidio.agentscope.harness.agent.filesystem.remote.store.StoreItemvoidbooleanList<io.agentscope.harness.agent.filesystem.remote.store.StoreItem>
-
Field Details
-
DEFAULT_TABLE_NAME
Default table name used when the builder is not customised.- See Also:
-
-
Method Details
-
builder
Creates a builder forPostgresBaseStore. -
get
public io.agentscope.harness.agent.filesystem.remote.store.StoreItem get(List<String> namespace, String key) - Specified by:
getin interfaceio.agentscope.harness.agent.filesystem.remote.store.BaseStore
-
put
- Specified by:
putin interfaceio.agentscope.harness.agent.filesystem.remote.store.BaseStore
-
putIfVersion
public boolean putIfVersion(List<String> namespace, String key, Map<String, Object> value, long expectedVersion) - Specified by:
putIfVersionin interfaceio.agentscope.harness.agent.filesystem.remote.store.BaseStore
-
search
public List<io.agentscope.harness.agent.filesystem.remote.store.StoreItem> search(List<String> namespace, int limit, int offset) - Specified by:
searchin interfaceio.agentscope.harness.agent.filesystem.remote.store.BaseStore
-
delete
- Specified by:
deletein interfaceio.agentscope.harness.agent.filesystem.remote.store.BaseStore
-