session

package
v0.0.0-...-76f8149 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SessionFlagNone = iota
	SessionFlagModify
	SessionFlagLoad
)

Variables

View Source
var (
	ErrSessionNotExist      = errors.New("session not exists")
	ErrKeyNotExistInSession = errors.New("key not exists in session")
)

Functions

func Init

func Init(provider string, addr string, options ...string) (err error)

provider: 1. memory, 返回一个内存的session管理类 2. redis, 返回一个redis的session管理类

Types

type MemorySession

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

func NewMemorySession

func NewMemorySession(id string) *MemorySession

func (*MemorySession) Del

func (m *MemorySession) Del(key string) (err error)

func (*MemorySession) Get

func (m *MemorySession) Get(key string) (value interface{}, err error)

func (*MemorySession) Id

func (m *MemorySession) Id() string

func (*MemorySession) IsModify

func (m *MemorySession) IsModify() bool

func (*MemorySession) Save

func (m *MemorySession) Save() (err error)

func (*MemorySession) Set

func (m *MemorySession) Set(key string, value interface{}) (err error)

type MemorySessionMgr

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

func (*MemorySessionMgr) CreateSession

func (s *MemorySessionMgr) CreateSession() (session Session, err error)

func (*MemorySessionMgr) Get

func (s *MemorySessionMgr) Get(sessionId string) (session Session, err error)

func (*MemorySessionMgr) Init

func (s *MemorySessionMgr) Init(addr string, options ...string) (err error)

type RedisSession

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

func NewRedisSession

func NewRedisSession(id string, pool *redis.Pool) *RedisSession

func (*RedisSession) Del

func (r *RedisSession) Del(key string) error

func (*RedisSession) Get

func (r *RedisSession) Get(key string) (result interface{}, err error)

func (*RedisSession) Id

func (m *RedisSession) Id() string

func (*RedisSession) IsModify

func (m *RedisSession) IsModify() bool

func (*RedisSession) Save

func (r *RedisSession) Save() (err error)

func (*RedisSession) Set

func (r *RedisSession) Set(key string, value interface{}) error

type RedisSessionMgr

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

func (*RedisSessionMgr) CreateSession

func (r *RedisSessionMgr) CreateSession() (session Session, err error)

func (*RedisSessionMgr) Get

func (r *RedisSessionMgr) Get(sessionId string) (session Session, err error)

func (*RedisSessionMgr) Init

func (r *RedisSessionMgr) Init(addr string, options ...string) (err error)

type Session

type Session interface {
	Set(key string, value interface{}) error
	Get(key string) (interface{}, error)
	Del(key string) error
	Save() error
	IsModify() bool

	Id() string
}

func CreateSession

func CreateSession() (session Session, err error)

func Get

func Get(sessionId string) (session Session, err error)

type SessionMgr

type SessionMgr interface {
	Init(addr string, options ...string) (err error)
	CreateSession() (session Session, err error)
	Get(sessionId string) (session Session, err error)
}

func NewMemorySessionMgr

func NewMemorySessionMgr() SessionMgr

func NewRedisSessionMgr

func NewRedisSessionMgr() SessionMgr

Jump to

Keyboard shortcuts

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