redis

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: Apache-2.0 Imports: 10 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Session

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

Session 生命周期应该和 http 请求保持一致

func (*Session) Claims

func (sess *Session) Claims() session.Claims

func (*Session) Del

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

func (*Session) Destroy

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

func (*Session) Get

func (sess *Session) Get(ctx context.Context, key string) ekit.AnyValue

func (*Session) Set

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

type SessionProvider

type SessionProvider struct {
	TokenCarrier session.TokenCarrier
	// contains filtered or unexported fields
}

SessionProvider 默认情况下,产生的 Session 一个 token, 而如何返回,以及如何携带,取决于具体的 TokenCarrier 实现 很多字段并没有暴露,如果你需要自定义,可以发 issue

func NewSessionProvider

func NewSessionProvider(client redis.Cmdable, jwtKey string,
	expiration time.Duration) *SessionProvider

NewSessionProvider 用于管理 Session

func (*SessionProvider) Destroy

func (rsp *SessionProvider) Destroy(ctx *gctx.Context) error

func (*SessionProvider) Get

func (rsp *SessionProvider) Get(ctx *gctx.Context) (session.Session, error)

Get 返回 Session,如果没有拿到 session 或者 session 已经过期,会返回 error

func (*SessionProvider) NewSession

func (rsp *SessionProvider) NewSession(ctx *gctx.Context,
	uid int64,
	jwtData map[string]string,
	sessData map[string]any) (session.Session, error)

NewSession 的时候,要先把这个 data 写入到对应的 token 里面

func (*SessionProvider) RenewAccessToken

func (rsp *SessionProvider) RenewAccessToken(ctx *ginx.Context) error

func (*SessionProvider) UpdateClaims

func (rsp *SessionProvider) UpdateClaims(ctx *gctx.Context, claims session.Claims) error

UpdateClaims 在这个实现里面,claims 同时写进去了

Jump to

Keyboard shortcuts

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