session

package
v6.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SESS_KEY_USERID       = "uid"
	SESS_KEY_LASTLDAPSYNC = "last_ldap_sync"
)

Variables

View Source
var GetSessionCount func() int
View Source
var StartSessionGC func() = func() {}

Functions

func Init

func Init(options *ms.Options, connMaxLifetime int64)

Types

type MysqlProvider

type MysqlProvider struct {
	// contains filtered or unexported fields
}

MysqlProvider represents a mysql session provider implementation.

func (*MysqlProvider) Count

func (p *MysqlProvider) Count() (total int)

Count counts and returns number of sessions.

func (*MysqlProvider) Destory

func (p *MysqlProvider) Destory(sid string) error

Destory deletes a session by session ID.

func (*MysqlProvider) Exist

func (p *MysqlProvider) Exist(sid string) bool

Exist returns true if session with given ID exists.

func (*MysqlProvider) GC

func (p *MysqlProvider) GC()

GC calls GC to clean expired sessions.

func (*MysqlProvider) Init

func (p *MysqlProvider) Init(expire int64, connStr string) (err error)

Init initializes mysql session provider. connStr: username:password@protocol(address)/dbname?param=value

func (*MysqlProvider) Read

func (p *MysqlProvider) Read(sid string) (session.RawStore, error)

Read returns raw session store by session ID.

func (*MysqlProvider) Regenerate

func (p *MysqlProvider) Regenerate(oldsid, sid string) (_ session.RawStore, err error)

Regenerate regenerates a session store from old session ID to new one.

type MysqlStore

type MysqlStore struct {
	// contains filtered or unexported fields
}

MysqlStore represents a mysql session store implementation.

func NewMysqlStore

func NewMysqlStore(c *sql.DB, sid string, kv map[interface{}]interface{}, expiry int64) *MysqlStore

NewMysqlStore creates and returns a mysql session store.

func (*MysqlStore) Delete

func (s *MysqlStore) Delete(key interface{}) error

Delete delete a key from session.

func (*MysqlStore) Flush

func (s *MysqlStore) Flush() error

Flush deletes all session data.

func (*MysqlStore) Get

func (s *MysqlStore) Get(key interface{}) interface{}

Get gets value by given key in session.

func (*MysqlStore) ID

func (s *MysqlStore) ID() string

ID returns current session ID.

func (*MysqlStore) Release

func (s *MysqlStore) Release() error

Release releases resource and save data to provider.

func (*MysqlStore) Set

func (s *MysqlStore) Set(key, val interface{}) error

Set sets value to given key in session.

type SessionStore

type SessionStore interface {
	// Set sets value to given key in session.
	Set(interface{}, interface{}) error
	// Get gets value by given key in session.
	Get(interface{}) interface{}
	// Delete deletes a key from session.
	Delete(interface{}) interface{}
	// ID returns current session ID.
	ID() string
	// Release releases session resource and save data to provider.
	Release() error
	// Destory deletes a session.
	Destory(*macaron.Context) error
	// init
	Start(*macaron.Context) error
	// RegenerateId regenerates the session id
	RegenerateId(*macaron.Context) error
}

func GetSession

func GetSession() SessionStore

type SessionWrapper

type SessionWrapper struct {
	// contains filtered or unexported fields
}

func (*SessionWrapper) Delete

func (s *SessionWrapper) Delete(k interface{}) interface{}

func (*SessionWrapper) Destory

func (s *SessionWrapper) Destory(c *macaron.Context) error

func (*SessionWrapper) Get

func (s *SessionWrapper) Get(k interface{}) interface{}

func (*SessionWrapper) ID

func (s *SessionWrapper) ID() string

func (*SessionWrapper) RegenerateId

func (s *SessionWrapper) RegenerateId(c *macaron.Context) error

func (*SessionWrapper) Release

func (s *SessionWrapper) Release() error

func (*SessionWrapper) Set

func (s *SessionWrapper) Set(k interface{}, v interface{}) error

func (*SessionWrapper) Start

func (s *SessionWrapper) Start(c *macaron.Context) error

Jump to

Keyboard shortcuts

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