sqlstore

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: Apache-2.0 Imports: 14 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultInterval = time.Minute * 5
View Source
var ErrSessionExpired = errors.New("Session expired")

Functions

This section is empty.

Types

type Options

type Options struct {
	Table         string        `json:"table"`
	KeyPrefix     string        `json:"keyPrefix"`
	KeyPairs      [][]byte      `json:"-"`
	MaxAge        int           `json:"maxAge"`
	EmptyDataAge  int           `json:"emptyDataAge"`
	MaxLength     int           `json:"maxLength"`
	CheckInterval time.Duration `json:"checkInterval"`
	MaxReconnect  int           `json:"maxReconnect"`
	// contains filtered or unexported fields
}

func (*Options) SetDDL

func (o *Options) SetDDL(ddl string) *Options

type SQLStore

type SQLStore struct {
	Codecs []securecookie.Codec
	// contains filtered or unexported fields
}

func New

func New(db *sql.DB, cfg *Options) (*SQLStore, error)

New .

func (*SQLStore) Cleanup

func (m *SQLStore) Cleanup(interval time.Duration) (chan<- struct{}, <-chan struct{})

Cleanup runs a background goroutine every interval that deletes expired sessions from the database.

The design is based on https://github.com/yosssi/boltstore

func (*SQLStore) Close

func (m *SQLStore) Close() (err error)

func (*SQLStore) Delete

func (m *SQLStore) Delete(ctx echo.Context, session *sessions.Session) error

func (*SQLStore) Get

func (m *SQLStore) Get(ctx echo.Context, name string) (*sessions.Session, error)

func (*SQLStore) Init

func (m *SQLStore) Init()

func (*SQLStore) MaxAge

func (m *SQLStore) MaxAge(ctx echo.Context, session *sessions.Session) int

func (*SQLStore) MaxLength

func (m *SQLStore) MaxLength(l int)

MaxLength restricts the maximum length of new sessions to l. If l is 0 there is no limit to the size of a session, use with caution. The default for a new FilesystemStore is 4096.

func (*SQLStore) New

func (m *SQLStore) New(ctx echo.Context, name string) (*sessions.Session, error)

func (*SQLStore) Reload

func (m *SQLStore) Reload(ctx echo.Context, session *sessions.Session) error

func (*SQLStore) Remove

func (m *SQLStore) Remove(sessionID string) error

func (*SQLStore) Save

func (m *SQLStore) Save(ctx echo.Context, session *sessions.Session) error

func (*SQLStore) StopCleanup

func (m *SQLStore) StopCleanup(quit chan<- struct{}, done <-chan struct{})

StopCleanup stops the background cleanup from running.

Jump to

Keyboard shortcuts

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