NAME

Net::Blossom::Server::Backend::Postgres::MetadataStore - PostgreSQL Blossom metadata

DESCRIPTION

This module implements Net::Blossom::Server::MetadataStore using PostgreSQL. It stores descriptors and owners but not blob bytes.

Use the same DBI handle for the paired Net::Blossom::Server::Backend::Postgres::BlobStore so their changes share one transaction.

lock_blob and all methods that change records require a transaction started by with_transaction.

deploy_schema requires AutoCommit. It serializes concurrent deployments and builds missing indexes without blocking ordinary metadata writes. An invalid index left by an interrupted build is replaced automatically.

CONSTRUCTOR

new

my $metadata = Net::Blossom::Server::Backend::Postgres::MetadataStore->new(
    dbh => $dbh,
);

Creates a metadata store in the current PostgreSQL schema using a PostgreSQL DBI handle with AutoCommit enabled.

METHODS

dbh

Returns the PostgreSQL DBI handle.

schema

Returns the schema selected when the component was created.

deploy_schema

Creates storage-neutral metadata tables and the owner lookup indexes. Missing indexes are built concurrently.

with_transaction

Runs a callback in a PostgreSQL transaction.

lock_blob

Takes a transaction-level advisory lock for one SHA-256 hash.

find_blob

Returns one storage-neutral blob record by SHA-256.

insert_blob

Inserts a blob record and reports whether it was created.

upsert_owner

Creates or updates one owner record.

delete_owner

Deletes one owner record and reports whether it existed.

delete_owners

Deletes every owner record for a blob.

owner_count

Returns the number of owners for a blob.

delete_blob

Deletes one blob metadata record and reports whether it existed.

list_blobs

Returns ordered storage-neutral blob records for an owner.

BUILDARGS

Validates and normalizes constructor arguments for Class::Tiny.