Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrSessionExpired 表示会话已经过期 ErrSessionExpired = errors.New("会话已过期") )
Functions ¶
This section is empty.
Types ¶
type AesStorage ¶
type AesStorage struct {
// contains filtered or unexported fields
}
AesStorage 是用aes加密用户信息的方式做会话存储的一种实现
func NewAesStorage ¶
func NewAesStorage(saes *util.SimpleAES) *AesStorage
NewAesStorage 构造AesStorage
func (*AesStorage) Get ¶
func (s *AesStorage) Get(key string, session interface{}) error
Get 实现Storage
func (*AesStorage) RefreshTTL ¶
func (s *AesStorage) RefreshTTL(key string, ttl time.Duration) error
RefreshTTL 实现Storage
type MysqlStorage ¶
type MysqlStorage struct {
// contains filtered or unexported fields
}
MysqlStorage 是存储在mysql中的会话
func NewMysqlStorage ¶
func NewMysqlStorage(db *gorm.DB) *MysqlStorage
NewMysqlStorage 构造MysqlStorage
func (*MysqlStorage) Get ¶
func (s *MysqlStorage) Get(key string, session interface{}) error
Get 实现Storage
func (*MysqlStorage) RefreshTTL ¶
func (s *MysqlStorage) RefreshTTL(key string, ttl time.Duration) error
RefreshTTL 实现Storage
type RedisStorage ¶
type RedisStorage struct {
// contains filtered or unexported fields
}
RedisStorage redis实现的Storage
func (*RedisStorage) Get ¶
func (s *RedisStorage) Get(key string, session interface{}) (err error)
Get 实现Storage
func (*RedisStorage) RefreshTTL ¶
func (s *RedisStorage) RefreshTTL(key string, ttl time.Duration) error
RefreshTTL 实现Storage
type Storage ¶
type Storage interface { Get(key string, session interface{}) error // 获取会话 Set(session interface{}, ttl time.Duration) (key string, err error) // 存储会话 ttl=0表示不会失效 RefreshTTL(key string, ttl time.Duration) error // 刷新会话存活时间 在原来过期时间基础上增加ttl Del(key string) error // 删除会话 }
Storage 是会话信息存储器
func NewRedisStorage ¶
NewRedisStorage 构造redis实现的Storage
Click to show internal directories.
Click to hide internal directories.