postgres

package
v0.0.0-...-24fb135 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package postgres has a storage provider that uses a PostgreSQL database table.

The database table is expected to have the following structure:

create table <table_name>(
  id character varying(255) primary key,
  version integer null,
  expires_at timestamp with time zone null,
  format character varying null,
  data bytea null
)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

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

Provider provides storage for sessions using a PostgreSQL table. It implements the storage.Provider interface.

The structure of the SQL table is described in the package comment.

func New

func New(db *sql.DB, tableName string) *Provider

New creates a new Provider given a database handle and the PostgreSQL table name.

func (*Provider) CreateTable

func (db *Provider) CreateTable() error

CreateTable creates the dynamodb table.

func (*Provider) Delete

func (db *Provider) Delete(ctx context.Context, id string) error

Delete implements the storage.Provider interface.

func (*Provider) DropTable

func (db *Provider) DropTable() error

DropTable deletes the DynamoDB table.

func (*Provider) Fetch

func (db *Provider) Fetch(ctx context.Context, id string) (*storage.Record, error)

Fetch implements the storage.Provider interface.

func (*Provider) Purge

func (db *Provider) Purge(ctx context.Context) error

Purge deletes all expired records.

func (*Provider) Save

func (db *Provider) Save(ctx context.Context, rec *storage.Record, oldVersion int64) error

Save implements the storage.Provider interface.

Jump to

Keyboard shortcuts

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