session

package
v0.0.0-...-31ad618 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Unlicense Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NotFound = errors.New("key not found in store")

Functions

This section is empty.

Types

type Keeper

type Keeper struct {
	sync.Mutex
	list.List
	Store
	// contains filtered or unexported fields
}

func NewKeeper

func NewKeeper(store Store, offloadAfter time.Duration) *Keeper

func (*Keeper) Destroy

func (k *Keeper) Destroy(key Key) error

func (*Keeper) GC

func (k *Keeper) GC(ctx context.Context)

func (*Keeper) Get

func (k *Keeper) Get(key Key) (any, error)

func (*Keeper) Keep

func (k *Keeper) Keep(value any) (Key, error)

type Key

type Key string

type Session

type Session struct {
	Key   Key
	Value any
	// contains filtered or unexported fields
}

type Store

type Store interface {
	Retrieve(Key) (any, error)

	// Store a new session
	Put(Session) error

	// Remove session
	Erase(Key) error

	// Refresh the expire of these sessions
	UpdateExpiration(...Session) error

	// Remove stale sessions
	CollectExpired() error
}

Store represent the long time storage backing for sessions

Jump to

Keyboard shortcuts

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