Documentation
¶
Index ¶
- Variables
- type RedisCodeCache
- type RedisTokenCache
- func (r *RedisTokenCache) Del(ctx context.Context, tokenId string) error
- func (r *RedisTokenCache) Get(ctx context.Context, tokenId string) (string, error)
- func (r *RedisTokenCache) Set(ctx context.Context, tokenId, value string, expire time.Duration) error
- func (r *RedisTokenCache) TTL(ctx context.Context, tokenId string) (time.Duration, error)
- type TokenCache
- type VerifyCodeCache
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrCodeRepeated = errors.New("code repeated")
)
Functions ¶
This section is empty.
Types ¶
type RedisCodeCache ¶
type RedisCodeCache struct {
// contains filtered or unexported fields
}
RedisCodeCache implements VerifyCodeCache with redis cache
func NewRedisCodeCache ¶
func NewRedisCodeCache(cache *redis.Client) *RedisCodeCache
type RedisTokenCache ¶
type RedisTokenCache struct {
// contains filtered or unexported fields
}
RedisTokenCache implements TokenCache interface for redis storage
func NewRedisTokenCache ¶
func NewRedisTokenCache(prefix string, client *redis.Client) *RedisTokenCache
func (*RedisTokenCache) Del ¶
func (r *RedisTokenCache) Del(ctx context.Context, tokenId string) error
type TokenCache ¶
type TokenCache interface { // Get returns the given tokenId from the cache, just verifying if it exists Get(ctx context.Context, tokenId string) (string, error) // TTL returns the rest life-time of the given token TTL(ctx context.Context, tokenId string) (time.Duration, error) // Del removes the specified tokenId from the cache Del(ctx context.Context, tokenId string) error // Set sets the specified tokenId to the cache Set(ctx context.Context, tokenId, value string, expire time.Duration) error }
TokenCache stores the token in the cache, and maintains them.
type VerifyCodeCache ¶
type VerifyCodeCache interface { // Set storage code into cache with ttl, return false if retry failed. Set(ctx context.Context, usage auth.Usage, code, to string, ttl, retry time.Duration) (bool, error) // Get returns the specified code Get(ctx context.Context, usage auth.Usage, code string) (string, error) // Del remove the specified code from cache Del(ctx context.Context, usage auth.Usage, code string) error }
VerifyCodeCache is responsible for storing verification code into cache
Click to show internal directories.
Click to hide internal directories.