Documentation
¶
Overview ¶
Package cache provides in-memory caching with a built-in captcha store.
The local cache is backed by gkit's local_cache and supports TTL-based expiration. The Base64CaptchaStore implements the captcha store interface for verification code storage.
Index ¶
- func Local() local_cache.Cache
- func Redis(driver ...string) *redis.Client
- func RedisDel(key string)
- func RedisHOQ[T any](key string, queryFunc func() (data T, exp time.Duration, err error)) (T, error)
- func RedisHOQGob[T any](key string, queryFunc func() (T, time.Duration, error)) (T, error)
- func RedisHasOrQuery(key string, queryFunc func() (data string, exp time.Duration)) stringdeprecated
- func RedisHasOrQueryByte(key string, queryFunc func() (data []byte, exp time.Duration)) []byte
- func RedisHasOrQuerySerializerGob[T any](key string, resultReceiver *T, ...) errordeprecated
- func RedisStrGet(key string) string
- func RedisStrSet(key, value string, exp time.Duration)
- type Base64CaptchaStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Local ¶
func Local() local_cache.Cache
func RedisHOQ ¶
func RedisHOQ[T any](key string, queryFunc func() (data T, exp time.Duration, err error)) (T, error)
RedisHOQ is a generic function that attempts to retrieve data from Redis cache using the provided key. If the data is not found in the cache, it executes the provided query function to fetch the data, caches it, and returns it. It uses singleflight to ensure that only one query is executed for a given key at a time.