redis

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

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

Provider Redis Session 提供者

func NewProvider

func NewProvider(client redis.Cmdable, jwtKey string, accessExpire, refreshExpire time.Duration, tokenCarrier session.TokenCarrier) *Provider

NewProvider 创建 Redis Session 提供者 client: Redis 客户端 jwtKey: JWT 签名密钥 accessExpire: Access Token 过期时间(建议 15 分钟 - 2 小时) refreshExpire: Refresh Token 过期时间(建议 7 天 - 30 天) tokenCarrier: Token 载体(如何传输 Token)

func (*Provider) Destroy

func (p *Provider) Destroy(ctx *gctx.Context) error

Destroy 销毁会话

func (*Provider) Get

func (p *Provider) Get(ctx *gctx.Context) (session.Session, error)

Get 获取会话

func (*Provider) NewSession

func (p *Provider) NewSession(ctx *gctx.Context, userId string, jwtData map[string]string, sessData map[string]any) (session.Session, error)

NewSession 创建新会话

func (*Provider) RenewToken

func (p *Provider) RenewToken(ctx *gctx.Context) error

RenewToken 刷新 Token(使用 Refresh Token 获取新的 Access Token)

type Session

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

Session Redis 会话实现

func (*Session) Claims

func (s *Session) Claims() *jwt.Claims

Claims 获取 JWT 声明

func (*Session) Del

func (s *Session) Del(ctx context.Context, key string) error

Del 删除会话数据

func (*Session) Destroy

func (s *Session) Destroy(ctx context.Context) error

Destroy 销毁会话

func (*Session) Get

func (s *Session) Get(ctx context.Context, key string) (any, error)

Get 获取会话数据

func (*Session) Refresh

func (s *Session) Refresh(ctx context.Context) error

Refresh 刷新会话过期时间

func (*Session) Set

func (s *Session) Set(ctx context.Context, key string, val any) error

Set 设置会话数据

Jump to

Keyboard shortcuts

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