session

package
v0.0.0-...-bfcc399 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Session

type Session struct {
	SID        string
	CookieName string

	AccessedTime time.Time // 最后访问时间
	MaxAge       int       // 超时时间
	Data         map[string]interface{}
	// contains filtered or unexported fields
}

func (*Session) Del

func (s *Session) Del(key string)

func (*Session) Get

func (s *Session) Get(key string) interface{}

func (*Session) Set

func (s *Session) Set(key string, value interface{})

type Sessioner

type Sessioner interface {
	Set(key string, value interface{}) // 设置Session值
	Get(key string) interface{}        // 获取Session值
	Del(key string)                    // 删除Session值
}

type Storage

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

func (*Storage) Destroy

func (st *Storage) Destroy(sid string) error

func (*Storage) Exists

func (st *Storage) Exists(sid string) bool

func (*Storage) NewCookie

func (st *Storage) NewCookie(session *Session) *http.Cookie

func (*Storage) NewSession

func (st *Storage) NewSession(sid, cookieName string, maxAge int) *Session

func (*Storage) Read

func (st *Storage) Read(sid string) (*Session, error)

func (*Storage) Save

func (st *Storage) Save(session *Session) error

func (*Storage) Update

func (st *Storage) Update(sid string, t string) error

type Storager

type Storager interface {
	NewCookie(session *Session) *http.Cookie
	NewSession(sid, cookieName string, maxAge int) *Session
	Save(session *Session) error
	Read(sid string) (*Session, error)
	Destroy(sid string) error
	Exists(sid string) bool
	Update(sid, t string) error
}

func NewStorage

func NewStorage(pool *redis.Pool) Storager

Jump to

Keyboard shortcuts

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