session

package
v0.6.12 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2022 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

View Source
const (
	MAX_TIMEOUT     = 86400 * 30 // 接近无限时间
	SESS_ONLINE_KEY = "onlines"  // 在线用户
	SESS_TOKEN_KEY  = "_token_"
	SESS_PREFIX     = "sess" // 会话缓存前缀
	SESS_TIMEOUT    = 7200   // 会话缓存时间
	SESS_LIST_SEP   = ";"    // 角色名之间的分隔符
)

Variables

This section is empty.

Functions

func SessListJoin

func SessListJoin(data []string) string

func SessListSplit

func SessListSplit(data string) []string

Types

type Session

type Session struct {
	*redisw.RedisHash
	// contains filtered or unexported fields
}

func NewSession

func NewSession(reg *SessionRegistry, key string) *Session

func (*Session) AddFlash

func (sess *Session) AddFlash(messages ...string) (int, error)

func (*Session) BindRoles

func (sess *Session) BindRoles(uid string, roles []string, kick bool) (string, error)

绑定用户角色,返回旧的sid

func (*Session) GetFlashes

func (sess *Session) GetFlashes(n int) ([]string, error)

数量n为最大取出多少条消息,-1表示所有消息

func (*Session) GetKey

func (sess *Session) GetKey() string

type SessionRegistry

type SessionRegistry struct {
	Onlines *redisw.RedisHash
	*redisw.RedisWrapper
	// contains filtered or unexported fields
}

func NewRegistry

func NewRegistry(params redisw.ConnParams) *SessionRegistry

func (*SessionRegistry) DelSession

func (sr *SessionRegistry) DelSession(token string) bool

func (SessionRegistry) GetKey

func (sr SessionRegistry) GetKey(token string) string

func (*SessionRegistry) GetSession

func (sr *SessionRegistry) GetSession(token string) *Session

Jump to

Keyboard shortcuts

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