cache

package
v0.0.0-...-65546df Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCodeRepeated = errors.New("code repeated")
)

Functions

This section is empty.

Types

type CaptchaCache

type CaptchaCache interface {
	// Set storage code into cache with ttl, return false if retry failed.
	Set(ctx context.Context, usage types.Usage, code, to string, ttl, retry time.Duration) (bool, error)
	// Get returns the specified code
	Get(ctx context.Context, usage types.Usage, code string) (string, error)
	// Del remove the specified code from cache
	Del(ctx context.Context, usage types.Usage, code string) error
}

CaptchaCache is responsible for storing captcha code into cache

type RedisCaptchaCache

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

RedisCaptchaCache implements CaptchaCache with redis cache

func NewRedisCaptchaCache

func NewRedisCaptchaCache(cache *redis.Client) *RedisCaptchaCache

func (*RedisCaptchaCache) Del

func (r *RedisCaptchaCache) Del(ctx context.Context, usage types.Usage, code string) error

func (*RedisCaptchaCache) Get

func (r *RedisCaptchaCache) Get(ctx context.Context, usage types.Usage, code string) (string, error)

func (*RedisCaptchaCache) Set

func (r *RedisCaptchaCache) Set(ctx context.Context, usage types.Usage, code, to string, ttl, retry time.Duration) (bool, error)

Jump to

Keyboard shortcuts

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