store

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: MIT Imports: 10 Imported by: 3

Documentation

Overview

package store contains store implementations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Memory

type Memory struct {
	Coder session.StoreCoder
	// contains filtered or unexported fields
}

Memory stores session data in memory

func (*Memory) Del

func (s *Memory) Del(_ context.Context, key string) error

Del deletes session data from memory

func (*Memory) GC

func (s *Memory) GC()

GC runs gc

func (*Memory) GCEvery

func (s *Memory) GCEvery(d time.Duration) *Memory

GCEvery starts gc every given duration

func (*Memory) Get

func (s *Memory) Get(_ context.Context, key string) (session.Data, error)

Get gets session data from memory

func (*Memory) Set

func (s *Memory) Set(_ context.Context, key string, value session.Data, opt session.StoreOption) error

Set sets session data to memory

type Redis added in v0.18.0

type Redis struct {
	Client *redis.Client
	Prefix string
	Coder  session.StoreCoder
}

Redis is the redis store implement by using "github.com/redis/go-redis/v9" package

func (*Redis) Del added in v0.18.0

func (s *Redis) Del(ctx context.Context, key string) error

Del deletes session data from redis

func (*Redis) Get added in v0.18.0

func (s *Redis) Get(ctx context.Context, key string) (session.Data, error)

Get gets session data from redis

func (*Redis) Set added in v0.18.0

func (s *Redis) Set(ctx context.Context, key string, value session.Data, opt session.StoreOption) error

Set sets session data to redis

type Retry

type Retry struct {
	Store       session.Store
	MaxAttempts int
}

Retry reties store operation when failed

func (*Retry) Del

func (s *Retry) Del(ctx context.Context, key string) (err error)

Del deletes session data from wrapped store with retry

func (*Retry) Get

func (s *Retry) Get(ctx context.Context, key string) (r session.Data, err error)

Get gets session data from wrapped store with retry

func (*Retry) Set

func (s *Retry) Set(ctx context.Context, key string, value session.Data, opt session.StoreOption) (err error)

Set sets session data to wrapped store with retry

type SQL

type SQL struct {
	DB    *sql.DB
	Coder session.StoreCoder

	SetStatement string
	GetStatement string
	DelStatement string
	GCStatement  string
}

SQL is the sql store

func (*SQL) Del

func (s *SQL) Del(ctx context.Context, key string) error

Del deletes session data from sql db

func (*SQL) GC

func (s *SQL) GC() error

GC runs gc

func (*SQL) GCEvery

func (s *SQL) GCEvery(d time.Duration) *SQL

GCEvery runs gc every given duration

func (*SQL) GeneratePostgreSQLStatement

func (s *SQL) GeneratePostgreSQLStatement(table string, initSchema bool) *SQL

GeneratePostgrSQLStatement generates postgresql statement

func (*SQL) Get

func (s *SQL) Get(ctx context.Context, key string) (session.Data, error)

Get gets session data from sql db

func (*SQL) Set

func (s *SQL) Set(ctx context.Context, key string, value session.Data, opt session.StoreOption) error

Set sets session data to sql db

Jump to

Keyboard shortcuts

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