sessions

package
v0.0.0-...-1ba6274 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection interface {
	Find(context.Context, string) ([]byte, error)
	Delete(context.Context, string) error
	Add(context.Context, string, []byte, time.Time) error
	All(context.Context) (map[string][]byte, error)
	DeleteOld(context.Context, time.Time) error
}

type DB

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

func NewDB

func NewDB() *DB

func (*DB) Add

func (db *DB) Add(_ context.Context, token string, data []byte, expires time.Time) error

func (*DB) All

func (db *DB) All(_ context.Context) (map[string][]byte, error)

func (*DB) Delete

func (db *DB) Delete(_ context.Context, token string) error

func (*DB) DeleteOld

func (db *DB) DeleteOld(_ context.Context, old time.Time) error

func (*DB) Find

func (db *DB) Find(_ context.Context, token string) ([]byte, error)

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option

func Cleanup

func Cleanup(cleanup time.Duration) Option

Cleanup

func Database

func Database(db Connection) Option

Database

func Logger

func Logger(logger *slog.Logger) Option

Logger

func Timeout

func Timeout(timeout time.Duration) Option

type Store

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

func New

func New(opts ...Option) (*Store, error)

func (*Store) All

func (s *Store) All() (map[string][]byte, error)

func (*Store) Commit

func (s *Store) Commit(token string, data []byte, expires time.Time) error

func (*Store) Delete

func (s *Store) Delete(token string) error

func (*Store) Find

func (s *Store) Find(token string) ([]byte, bool, error)

func (*Store) StopCleanup

func (s *Store) StopCleanup()

Jump to

Keyboard shortcuts

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