session

package
v0.0.0-...-7a62063 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get[T any](s *Session, c echo.Context, name string) (T, error)

Get 从 cookie 读取 session 数据

Types

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session 基于 Redis Hash 的会话管理 Hash key = {name}:{uid},field = cookie UUID,value = JSON 数据 额外维护 lookup key = lookup:{name}:{cookie} → uid,用于 Get 时反查

func New

func New(cfg *config.Config) *Session

func (*Session) Del

func (s *Session) Del(c echo.Context, name string, uid uuid.UUID) error

Del 删除单个 session(登出)

func (*Session) Flush

func (s *Session) Flush(ctx context.Context, name string, uid uuid.UUID, data any) error

Flush 刷新用户所有 session 的数据

func (*Session) Save

func (s *Session) Save(c echo.Context, name string, uid uuid.UUID, data any) (string, error)

Save 创建 session,内部生成 UUID cookie 并设置到 response

func (*Session) Trunc

func (s *Session) Trunc(ctx context.Context, name string, uid uuid.UUID) error

Trunc 删除用户所有 session(踢人)

Jump to

Keyboard shortcuts

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