Documentation ¶
Index ¶
- type Manager
- func (m *Manager) GetSession(ctx context.Context, sessId string) (*model.Session, error)
- func (m *Manager) GetUserSessions(ctx context.Context, uid uint64) ([]*model.Session, error)
- func (m *Manager) InvalidateAll(ctx context.Context, uid uint64) error
- func (m *Manager) InvalidateSession(ctx context.Context, sessId string) error
- func (m *Manager) MarshalUserBase(user *dao.UserBase) (string, error)
- func (m *Manager) NewSession(ctx context.Context, user *dao.UserBase, platform string) (*model.Session, error)
- func (m *Manager) RenewSession(ctx context.Context, sessId string) error
- func (m *Manager) UnmarshalUserBase(data string) (*dao.UserBase, error)
- type RedisStore
- func (r *RedisStore) BatchDel(ctx context.Context, keys []string) error
- func (r *RedisStore) BatchGet(ctx context.Context, keys []string) ([]*model.Session, error)
- func (r *RedisStore) Del(ctx context.Context, key string) error
- func (r *RedisStore) DelUid(ctx context.Context, uid uint64) error
- func (r *RedisStore) Get(ctx context.Context, key string) (sess *model.Session, found bool, err error)
- func (r *RedisStore) GetUid(ctx context.Context, uid uint64) ([]*model.Session, error)
- func (r *RedisStore) Set(ctx context.Context, key string, sess *model.Session) error
- type RedisStoreOpt
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
管理session
func NewManager ¶
func (*Manager) InvalidateAll ¶
令某个用户的所有session立即失效
func (*Manager) InvalidateSession ¶
立即令session过期
func (*Manager) MarshalUserBase ¶
func (*Manager) NewSession ¶
func (m *Manager) NewSession(ctx context.Context, user *dao.UserBase, platform string) (*model.Session, error)
创建新的session并且保存
func (*Manager) RenewSession ¶
给一个已经存在的session续期
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
func (*RedisStore) BatchDel ¶
func (r *RedisStore) BatchDel(ctx context.Context, keys []string) error
type RedisStoreOpt ¶
type RedisStoreOpt func(*RedisStore)
func WithSerializer ¶
func WithSerializer(ser model.SessionSerializer) RedisStoreOpt
func WithSessPrefix ¶
func WithSessPrefix(px string) RedisStoreOpt
func WithUidPrefix ¶
func WithUidPrefix(px string) RedisStoreOpt
type Store ¶
type Store interface { // 获取id为key的session // 返回找到的session, 如果found为true, 表示没有对应的key的session // err不为nil时, 表示发生了系统错误 Get(ctx context.Context, key string) (sess *model.Session, found bool, err error) // 批量获取 BatchGet(ctx context.Context, keys []string) ([]*model.Session, error) // 获取uid所有的session GetUid(ctx context.Context, uid uint64) ([]*model.Session, error) // 设置id为key的session 存在则覆盖 Set(ctx context.Context, key string, sess *model.Session) error // 立即删除id为key的session, 如果不存在 则操作为no-op Del(ctx context.Context, key string) error // 批量删除sessId BatchDel(ctx context.Context, keys []string) error // 删除uid的所有session, 如果不存在, 则操作为no-op DelUid(ctx context.Context, uid uint64) error }
Store只提供存储功能
func NewRedisStore ¶
func NewRedisStore(cache *redis.Redis, opts ...RedisStoreOpt) Store
Click to show internal directories.
Click to hide internal directories.