mysql

package
v2.39.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const DDL = "CREATE TABLE IF NOT EXISTS %s (" +
	"	`id` char(64) NOT NULL," +
	"	`data` longblob NOT NULL," +
	"	`created` int(11) unsigned NOT NULL DEFAULT '0'," +
	"	`modified` int(11) unsigned NOT NULL DEFAULT '0'," +
	"	`expires` int(11) unsigned NOT NULL DEFAULT '0'," +
	"	PRIMARY KEY (`id`)" +
	"  ) ENGINE=InnoDB;"

Variables

View Source
var DefaultInterval = time.Minute * 5
View Source
var (
	DefaultKeyPrefix = `_`
)
View Source
var DefaultMaxReconnect = 5

Functions

func New

func New(cfg *Options) sessions.Store

func Reg

func Reg(store sessions.Store, args ...string)

func RegWithOptions

func RegWithOptions(opts *Options, args ...string) sessions.Store

Types

type MySQLStore

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

func NewMySQLStore

func NewMySQLStore(cfg *Options) (*MySQLStore, error)

NewMySQLStore takes the following paramaters endpoint - A sql.Open style endpoint tableName - table where sessions are to be saved. Required fields are created automatically if the table doesnot exist. path - path for Set-Cookie header maxAge codecs

func NewMySQLStoreFromConnection

func NewMySQLStoreFromConnection(db *sql.DB, cfg *Options) (*MySQLStore, error)

NewMySQLStoreFromConnection .

func (*MySQLStore) Cleanup

func (m *MySQLStore) 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 (*MySQLStore) Close

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

func (*MySQLStore) Delete

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

func (*MySQLStore) Get

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

func (*MySQLStore) Init added in v1.6.0

func (m *MySQLStore) Init()

func (*MySQLStore) MaxAge added in v1.6.0

func (n *MySQLStore) MaxAge(ctx echo.Context) int

func (*MySQLStore) MaxLength added in v1.6.0

func (s *MySQLStore) 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 (*MySQLStore) New

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

func (*MySQLStore) Reload added in v1.6.0

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

func (*MySQLStore) Remove added in v1.6.0

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

func (*MySQLStore) Save

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

func (*MySQLStore) StopCleanup

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

StopCleanup stops the background cleanup from running.

type Options

type Options struct {
	Config        dbconfig.Config `json:"-"`
	Table         string          `json:"table"`
	KeyPairs      [][]byte        `json:"-"`
	MaxAge        int             `json:"maxAge"`
	MaxLength     int             `json:"maxLength"`
	CheckInterval time.Duration   `json:"checkInterval"`
	MaxReconnect  int             `json:"maxReconnect"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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