mirror of
https://github.com/quarkcloudio/quark-go.git
synced 2025-09-26 20:11:11 +08:00
23 lines
465 B
Go
23 lines
465 B
Go
package login
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/redis/go-redis/v9"
|
|
)
|
|
|
|
type CaptchaStore struct {
|
|
RedisClient *redis.Client
|
|
Expiration time.Duration
|
|
}
|
|
|
|
func (store *CaptchaStore) Set(id string, digits []byte) {
|
|
store.RedisClient.Set(context.Background(), id, string(digits), store.Expiration)
|
|
}
|
|
|
|
func (store *CaptchaStore) Get(id string, clear bool) (digits []byte) {
|
|
bytes, _ := store.RedisClient.Get(context.Background(), id).Bytes()
|
|
return bytes
|
|
}
|