Help us shape the future of Go! Take the 2026 Go Developer Survey

postgres

package
v0.0.0-...-15b5bb4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package postgres provides a durable multi-process task-result cache.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Clock defaults to UTC time.Now and is injectable for deterministic TTL tests.
	Clock func() time.Time
}

Options controls PostgreSQL cache behavior.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is a concurrency-safe PostgreSQL task cache.

func New

func New(db *sql.DB, options ...Options) (*Store, error)

New constructs a Store over an existing database handle without taking ownership.

func Open

func Open(ctx context.Context, dsn string, options ...Options) (*Store, error)

Open opens a pgx database/sql handle, applies the schema, and returns an owning Store.

func (*Store) Clear

func (s *Store) Clear(ctx context.Context, namespaces []string) error

Clear implements cache.Store. Nil namespaces clears all rows.

func (*Store) Close

func (s *Store) Close() error

Close closes only database handles owned by Open.

func (*Store) Get

func (s *Store) Get(ctx context.Context, keys []cache.Key) (map[cache.Key][]byte, error)

Get implements cache.Store with lazy transactional expiry deletion.

func (*Store) Set

func (s *Store) Set(ctx context.Context, items map[cache.Key]cache.Item) error

Set implements cache.Store as an atomic upsert transaction.

func (*Store) Setup

func (s *Store) Setup(ctx context.Context) error

Setup creates the cache schema under a transaction-scoped advisory lock.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL