session

package
v0.0.0-...-4ba6224 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewManagerMemory

func NewManagerMemory() *managerMemory

func NewManagerRedis

func NewManagerRedis(address string, password ...string) *managerRedis

Types

type Manager

type Manager interface {
	// RegisterSession 注册一个新的会话
	RegisterSession(sessionId string) (Session, error)
	// UnRegisterSession 注销一个会话
	UnRegisterSession(session Session) error
	// GetAllSession 获取所有会话
	GetAllSession() ([]Session, error)
	// GetSession 获取特定id的会话
	GetSession(sessionId string) (Session, error)
	// SetExpire 设置会话过期时间(默认 0, 永不过期)
	SetExpire(expire time.Duration) error
}

Manager 会话管理器实现

可供给各种用途使用session管理

type Session

type Session interface {
	// GetId 获取会话ID
	GetId() string
	// Store 向会话中存储数据
	Store(key string, data interface{}) error
	// Load 加载会话中的数据
	Load(key string) (interface{}, error)
	// Del 删除会话中的数据
	Del(key string) error
	// Close 结束会话
	Close() error
	// GetSessionManager 获取会话管理器
	GetSessionManager() Manager
	// IsExpire 是否已过期
	IsExpire() bool
	// SetExpire 设置过期时间
	SetExpire(expire time.Duration) error
}

Session 会话实现

Jump to

Keyboard shortcuts

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