mysql

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2019 License: Apache-2.0 Imports: 15 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 (
	DefaultMaxAge    = 86400
	DefaultKeyPrefix = `_`
)

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(endpoint string, tableName string, keyPairs ...[]byte) (*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, tableName string, keyPairs ...[]byte) (*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()

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) New

func (m *MySQLStore) New(ctx echo.Context, name string) (*sessions.Session, 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
	Table    string
	KeyPairs [][]byte
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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