redis

package
v0.0.0-...-04312dd Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTokenTOBlacklist

func AddTokenTOBlacklist(ctx context.Context, token string, expiration time.Duration) error

将 token 加入到黑名单

func AddUserToken

func AddUserToken(ctx context.Context, token string, userId string, expiration time.Duration) error

func CheckTenantDynamicToken

func CheckTenantDynamicToken(ctx context.Context, appId string, token string) bool

每次取用都延期,

func CheckTokenInBlack

func CheckTokenInBlack(ctx context.Context, token string) bool

检查token 是否在黑名单中

func CheckUserToken

func CheckUserToken(ctx context.Context, token string, userId string) bool

func CheckUserVerificationCode

func CheckUserVerificationCode(ctx context.Context, vo *UserVerificationCodeVo) bool

校验验证码 验证码正常校验之后就要删除

func NewRedisCache

func NewRedisCache(op *Option)

func SetTenantDynamicToken

func SetTenantDynamicToken(ctx context.Context, appId string, token string) error

租户的动态token 有效期只有20分钟 主要用于接口调试,过期了就要重新搞

func SetUserLoginCode

func SetUserLoginCode(ctx context.Context, vo *UserVerificationCodeVo) error

func SetUserResetPasswordCode

func SetUserResetPasswordCode(ctx context.Context, vo *UserVerificationCodeVo) error

func SetUserVerificationCode

func SetUserVerificationCode(ctx context.Context, vo *UserVerificationCodeVo) error

将验证码写入redis 默认有效时间为5分钟

Types

type Option

type Option struct {
	Addr                  string   `mapstructure:"addr" json:"addr" yaml:"addr" `
	DB                    int      `mapstructure:"db" json:"db" yaml:"db" `
	UserName              string   `mapstructure:"user-name" json:"user-name" yaml:"user-name" `
	Password              string   `mapstructure:"password" json:"password" yaml:"password" `
	EnableCluster         bool     `mapstructure:"is-cluster" json:"is-cluster" yaml:"is-cluster" `
	Addrs                 []string `mapstructure:"addrs" json:"addrs" yaml:"addrs" `
	MasterName            string   `mapstructure:"master-name" json:"master-name" yaml:"master-name" `
	MaxIdle               int      `mapstructure:"max-idle" json:"max-idle" yaml:"max-idle" `
	MaxActive             int      `mapstructure:"max-active" json:"max-active" yaml:"max-active" `
	Timeout               int      `mapstructure:"timeout" json:"timeout" yaml:"timeout" `
	UseSSL                bool     `mapstructure:"use-ssl" json:"use-ssl" yaml:"use-ssl" `
	SSLInsecureSkipVerify bool     `mapstructure:"ssl-insecure-skip-verify" json:"ssl-insecure-skip-verify" yaml:"ssl-insecure-skip-verify" `
}

type UserVerificationCodeVo

type UserVerificationCodeVo struct {
	UserId   uint
	Source   string
	Code     string
	CodeType string
}

func (*UserVerificationCodeVo) GetKey

func (u *UserVerificationCodeVo) GetKey() string

Jump to

Keyboard shortcuts

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