Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrCodeSendTooMany = errors.New("发送太频繁") ErrCodeVerifyTooManyTimes = errors.New("验证码错误或者失败太多次") ErrUnKnownForCode = errors.New("未知错误") )
View Source
var KeyNotExist = redis.Nil
Functions ¶
This section is empty.
Types ¶
type CodeCache ¶
type CodeCache interface { Set(ctx context.Context, biz string, phone string, code string) error Verify(ctx context.Context, biz string, phone string, inputCode string) (bool, error) }
func NewCodeCache ¶
func NewCodeCache(client redis.Cmdable) CodeCache
type RedisCodeCache ¶
type RedisCodeCache struct {
// contains filtered or unexported fields
}
type RedisUserCache ¶
type RedisUserCache struct {
// contains filtered or unexported fields
}
type UserCache ¶
type UserCache interface { FindById(ctx context.Context, id int64) (domain.User, error) Set(ctx context.Context, u domain.User) error }
func NewUserCache ¶
func NewUserCache(cmd redis.Cmdable) UserCache
面向接口编程,依赖注入,这里的cmd可以是本地的redis,也可以是集群的redis 这里的cmd是一个接口,它的实现是redis.Client和redis.ClusterClient
Click to show internal directories.
Click to hide internal directories.