自动更新依赖并发布版本
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package captcha
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitea.bvbej.com/bvbej/base-golang/pkg/cache"
|
||||
"github.com/mojocn/base64Captcha"
|
||||
@@ -12,7 +13,7 @@ import (
|
||||
var _ base64Captcha.Store = (*store)(nil)
|
||||
|
||||
type store struct {
|
||||
cache cache.Repo
|
||||
cache cache.RedisRepo
|
||||
ttl time.Duration
|
||||
logger *zap.Logger
|
||||
ns string
|
||||
@@ -20,7 +21,7 @@ type store struct {
|
||||
}
|
||||
|
||||
func (s *store) Set(id string, value string) error {
|
||||
err := s.cache.Set(fmt.Sprintf("%s%s%s", s.ns, s.prefix, id), value, s.ttl)
|
||||
err := s.cache.Set(context.Background(), fmt.Sprintf("%s%s%s", s.ns, s.prefix, id), value, s.ttl)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -28,9 +29,9 @@ func (s *store) Set(id string, value string) error {
|
||||
}
|
||||
|
||||
func (s *store) Get(id string, clear bool) string {
|
||||
value, err := s.cache.Get(fmt.Sprintf("%s%s%s", s.ns, s.prefix, id))
|
||||
value, err := s.cache.Get(context.Background(), fmt.Sprintf("%s%s%s", s.ns, s.prefix, id))
|
||||
if err == nil && clear {
|
||||
s.cache.Del(fmt.Sprintf("%s%s%s", s.ns, s.prefix, id))
|
||||
_, _ = s.cache.Del(context.Background(), fmt.Sprintf("%s%s%s", s.ns, s.prefix, id))
|
||||
}
|
||||
return value
|
||||
}
|
||||
@@ -43,7 +44,7 @@ func (s *store) Verify(id, answer string, clear bool) bool {
|
||||
return strings.ToLower(value) == strings.ToLower(answer)
|
||||
}
|
||||
|
||||
func NewStore(cache cache.Repo, ttl time.Duration, namespace string) base64Captcha.Store {
|
||||
func NewStore(cache cache.RedisRepo, ttl time.Duration, namespace string) base64Captcha.Store {
|
||||
return &store{
|
||||
cache: cache,
|
||||
ttl: ttl,
|
||||
|
||||
Reference in New Issue
Block a user