Documentation
¶
Index ¶
Constants ¶
View Source
const StoreKeyPrefix = "harborCaptcha:"
Variables ¶
Functions ¶
This section is empty.
Types ¶
type CaptchaRecord ¶
type CaptchaStore ¶
type CaptchaStore interface {
// Save 保存验证码记录
Save(ctx context.Context, key string, record *CaptchaRecord, ttl time.Duration) error
// Load 加载验证码记录
Load(ctx context.Context, key string) (*CaptchaRecord, error)
// Remove 删除验证码记录
Remove(ctx context.Context, key string) error
// Start 启动存储清理或初始化逻辑
Start()
}
type ClickDot ¶
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
func NewMemoryStore ¶
func NewMemoryStore(interval time.Duration) *MemoryStore
NewMemoryStore 创建内存存储实例
func (*MemoryStore) Load ¶
func (s *MemoryStore) Load(ctx context.Context, key string) (*CaptchaRecord, error)
Load 从内存加载验证码记录
func (*MemoryStore) Remove ¶
func (s *MemoryStore) Remove(ctx context.Context, key string) error
Remove 从内存删除验证码记录
func (*MemoryStore) Save ¶
func (s *MemoryStore) Save(ctx context.Context, key string, record *CaptchaRecord, ttl time.Duration) error
Save 保存验证码记录到内存
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
func NewRedisStore ¶
func NewRedisStore(client redis.UniversalClient) *RedisStore
NewRedisStore 创建Redis存储实例
func (*RedisStore) Load ¶
func (s *RedisStore) Load(ctx context.Context, key string) (*CaptchaRecord, error)
Load 从Redis加载验证码记录
func (*RedisStore) Remove ¶
func (s *RedisStore) Remove(ctx context.Context, key string) error
Remove 从Redis删除验证码记录
func (*RedisStore) Save ¶
func (s *RedisStore) Save(ctx context.Context, key string, record *CaptchaRecord, ttl time.Duration) error
Save 保存验证码记录到Redis
Source Files
¶
- captcha_store_interface.go
- store_memory.go
- store_redis.go
Click to show internal directories.
Click to hide internal directories.