Documentation
¶
Overview ¶
Package session 提供会话管理功能。
Package session 提供内存会话存储抽象层。
Index ¶
- Variables
- func InitSessionStore() error
- type MemoryStore
- func (m *MemoryStore) Delete(ctx context.Context, key string) error
- func (m *MemoryStore) Exists(ctx context.Context, key string) (bool, error)
- func (m *MemoryStore) Get(ctx context.Context, key string) (any, error)
- func (m *MemoryStore) Set(ctx context.Context, key string, value any, expiration time.Duration) error
- type SessionStore
- type StoreType
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrKeyNotFound = errors.New("session: key not found") ErrExpired = errors.New("session: key expired") )
错误定义
View Source
var GinStore sessions.Store
GinStore 全局 Gin 会话存储实例(用于 HTTP 会话)。
Functions ¶
func InitSessionStore ¶
func InitSessionStore() error
InitSessionStore 初始化会话存储。 STX 默认使用内存 SessionStore + Cookie Gin 会话。
Types ¶
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore 内存会话存储实现。
func (*MemoryStore) Delete ¶
func (m *MemoryStore) Delete(ctx context.Context, key string) error
Delete 从内存中删除指定 key。
type SessionStore ¶
type SessionStore interface {
Get(ctx context.Context, key string) (any, error)
Set(ctx context.Context, key string, value any, expiration time.Duration) error
Delete(ctx context.Context, key string) error
Exists(ctx context.Context, key string) (bool, error)
}
SessionStore 会话存储接口。
var Store SessionStore
Store 全局会话存储实例。
Click to show internal directories.
Click to hide internal directories.