cache

package
v0.0.0-...-b84db9d Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCodeSendTooMany        = errors.New("发送验证码太频繁")
	ErrCodeVerifyTooManyTimes = errors.New("验证次数太多")
	ErrUnknownForCode         = errors.New("我也不知发生什么了,反正是跟 code 有关")
)
View Source
var ErrKeyNotExist = redis.Nil

Functions

This section is empty.

Types

type Cache

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

func NewCache

func NewCache() *Cache

func (*Cache) Set

func (c *Cache) Set(biz, phone, code, cnt string, isInside bool) error

func (*Cache) Verify

func (c *Cache) Verify(biz, phone, code string) (bool, error)

type CodeLruCache

type CodeLruCache interface {
	Set(biz, phone, code string) error
	Verify(biz, phone, inputCode string) (bool, error)
}

type CodeRedisCache

type CodeRedisCache interface {
	Set(ctx context.Context, biz, phone, inputCode string) error
	Verify(ctx context.Context, biz, phone, inputCode string) (bool, error)
}

func NewCodeCache

func NewCodeCache(client redis.Cmdable) CodeRedisCache

type RedisCodeCache

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

func (*RedisCodeCache) Set

func (c *RedisCodeCache) Set(ctx context.Context, biz, phone, inputCode string) error

func (*RedisCodeCache) Verify

func (c *RedisCodeCache) Verify(ctx context.Context, biz, phone, inputCode string) (bool, error)

type RedisUserCache

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

func (*RedisUserCache) Get

func (cache *RedisUserCache) Get(ctx context.Context, id int64) (domain.User, error)

只要 error 为 nil,认为缓存一定有数据,如果无数据,返回特定的 error

func (*RedisUserCache) Set

func (cache *RedisUserCache) Set(ctx context.Context, u domain.User) error

type UserCache

type UserCache interface {
	Get(ctx context.Context, id int64) (domain.User, error)
	Set(ctx context.Context, u domain.User) error
}

func NewUserCache

func NewUserCache(client redis.Cmdable) UserCache

Directories

Path Synopsis
Package cachemocks is a generated GoMock package.
Package cachemocks is a generated GoMock package.
Package redismocks is a generated GoMock package.
Package redismocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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