telega_storage_postgres

PostgreSQL storage adapter for Telega.

Implements telega/storage.KeyValueStorage on top of a single Postgres table with a text value column, suitable for production bots. TTL is stored as an epoch-millisecond expires_at column and enforced lazily on access (get/scan), so no background job is required.

Values

pub fn migrate(
  conn: pog.Connection,
) -> Result(Nil, pog.QueryError)

Create the storage table if it does not exist. Run once at startup.

pub fn migrate_table(
  conn: pog.Connection,
  table: String,
) -> Result(Nil, pog.QueryError)

Create a custom-named storage table if it does not exist.

pub fn new(
  conn: pog.Connection,
) -> storage.KeyValueStorage(pog.QueryError)

Build a KeyValueStorage backed by the given pog connection.

Uses the default table name telega_storage. Call migrate once at startup to create the table.

pub fn new_with_table(
  conn: pog.Connection,
  table: String,
) -> storage.KeyValueStorage(pog.QueryError)

Like new, but with a custom table name.

Search Document