cache

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

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

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNextCodeTooSoon    = errors.New("验证码发送间隔过短")
	ErrInvalidCode        = errors.New("未知错误")
	ErrVerifyTooManyTimes = errors.New("验证码验证次数过多")
)

Functions

This section is empty.

Types

type ArticleCache

type ArticleCache interface {
	SetFirstPage(ctx context.Context, arts []domain.Article, authorId int64) error
	GetFirstPage(ctx context.Context, authorId int64) ([]domain.Article, error)
	EraseFirstPage(ctx context.Context, authorId int64) error
	Set(ctx context.Context, art domain.Article) error
	Get(ctx context.Context, id int64) (domain.Article, error)
	SetPub(ctx context.Context, art domain.PublishedArticle) error
	GetPub(ctx context.Context, id int64) (domain.PublishedArticle, error)
}

func NewArticleCache

func NewArticleCache(cmd redis.Cmdable) ArticleCache

type CodeCache

type CodeCache interface {
	Set(ctx context.Context, biz, phone, code string) error
	Verify(ctx context.Context, biz, phone, input string) (bool, error)
}

func NewRedisCodeCache

func NewRedisCodeCache(cmd redis.Cmdable) CodeCache

type LocalCodeCache

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

func NewLocalCodeCache

func NewLocalCodeCache(cache *lru.Cache, expiry time.Duration) *LocalCodeCache

func (*LocalCodeCache) Set

func (c *LocalCodeCache) Set(ctx context.Context, biz string, phone string, code string) error

func (*LocalCodeCache) Verify

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

type RankingCache

type RankingCache interface {
	ReplaceTopN(ctx context.Context, arts []domain.PublishedArticle) error
}

func NewRankingCache

func NewRankingCache(client redis.Cmdable, key string, expiration time.Duration) RankingCache

type RedisCodeCache

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

func (*RedisCodeCache) Set

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

func (*RedisCodeCache) Verify

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

type UserActivityCache

type UserActivityCache interface {
	IncrReadCntIfPresent(ctx context.Context, biz string, bizId int64) error
}

func NewUserActivityCache

func NewUserActivityCache(client redis.Cmdable) UserActivityCache

type UserCache

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

func NewRedisUserCache

func NewRedisUserCache(cmd redis.Cmdable) UserCache

type UserRedisCache

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

func (*UserRedisCache) Get

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

func (*UserRedisCache) Set

func (cache *UserRedisCache) Set(ctx context.Context, user domain.User) error

Jump to

Keyboard shortcuts

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