Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanCloverExpiration ¶ added in v1.3.0
CleanCloverExpiration clean clover cache expired records
func CleanFileExpiration ¶ added in v1.3.1
CleanFileExpiration clean file cache expired records
Types ¶
type Cache ¶
type Cache interface {
// Put a new value to cache
Put(key string, value any, ttl time.Duration) error
// PutForever put value with infinite ttl
PutForever(key string, value any) error
// Set Change value of cache item, return false if item not exists
Set(key string, value any) (bool, error)
// Get item from cache
Get(key string) (any, error)
// Exists check if item exists in cache
Exists(key string) (bool, error)
// Forget delete Item from cache
Forget(key string) error
// Pull item from cache and remove it
Pull(key string) (any, error)
// TTL get cache item ttl. this method returns -1 if item not exists
TTL(key string) (time.Duration, error)
// Cast parse cache item as caster
Cast(key string) (caster.Caster, error)
// IncrementFloat increment numeric item by float, return false if item not exists
IncrementFloat(key string, value float64) (bool, error)
// Increment increment numeric item by int, return false if item not exists
Increment(key string, value int64) (bool, error)
// DecrementFloat decrement numeric item by float, return false if item not exists
DecrementFloat(key string, value float64) (bool, error)
// Decrement decrement numeric item by int, return false if item not exists
Decrement(key string, value int64) (bool, error)
}
Cache interface for cache drivers.
func NewCloverCache ¶ added in v1.3.0
NewCloverCache create a new clover db cache manager instance
func NewFileCache ¶
NewFileCache create a new file cache manager instance
func NewRedisCache ¶
NewRedisCache create a new redis cache manager instance
type RateLimiter ¶
type RateLimiter interface {
// Hit decrease the allowed times
Hit() error
// Lock lock rate limiter
Lock() error
// Reset reset rate limiter
Reset() error
// Clear remove rate limiter record
Clear() error
// MustLock check if rate limiter must lock access
MustLock() (bool, error)
// TotalAttempts get user attempts count
TotalAttempts() (uint32, error)
// RetriesLeft get user retries left
RetriesLeft() (uint32, error)
// AvailableIn get time until unlock
AvailableIn() (time.Duration, error)
}
RateLimiter interface for rate limiter
func NewRateLimiter ¶
func NewRateLimiter(key string, maxAttempts uint32, ttl time.Duration, cache Cache) (RateLimiter, error)
NewRateLimiter create a new rate limiter
type VerificationCode ¶
type VerificationCode interface {
// Set set code
Set(value string) error
// Generate generate a random numeric code with 5 character length
Generate() (string, error)
// GenerateN generate a random numeric code with special character length
GenerateN(count uint) (string, error)
// Clear clear code
Clear() error
// Get get code
Get() (string, error)
// Exists check if code exists
Exists() (bool, error)
// TTL get ttl
TTL() (time.Duration, error)
}
VerificationCode interface for verification code
func NewVerificationCode ¶
NewVerificationCode create a new verification code manager instance
Click to show internal directories.
Click to hide internal directories.