Versions in this module Expand all Collapse all v0 v0.19.4 Nov 1, 2026 Changes in this version + const CompressionPrefix + const CompressionPrefixLen + const DefaultMaxEntries + var ErrCapacityExceeded = errors.New("cache capacity exceeded") + var ErrChannelClosed = fmt.Errorf("channel is closed") + var ErrClosed = errors.New("cache is closed") + var ErrCompressFailed = fmt.Errorf("compress data failed") + var ErrDataRead = errors.New("failed to read data from cache") + var ErrDataWrite = errors.New("failed to write data to cache") + var ErrDecompressFailed = fmt.Errorf("decompress data failed") + var ErrDelayQueueClosed = errors.New("delay queue is closed") + var ErrDelayQueueRunning = errors.New("delay queue consumer is already running") + var ErrDelayTaskNotFound = errors.New("delay task not found") + var ErrGetRedisLenFailed = fmt.Errorf("failed to get redis queue length") + var ErrInvalidBLPopResult = fmt.Errorf("invalid blpop result") + var ErrInvalidDelayTask = errors.New("invalid delay task: key required and execute time required") + var ErrInvalidKey = errors.New("invalid cache key") + var ErrInvalidTTL = errors.New("invalid TTL value") + var ErrInvalidValue = errors.New("invalid cache value") + var ErrLockExpired = errors.New("lock has expired") + var ErrLockNotFound = errors.New("lock not found") + var ErrLockNotObtained = errors.New("lock not obtained") + var ErrLockNotOwned = errors.New("lock not owned by this instance") + var ErrNoData = fmt.Errorf("no data available") + var ErrNotFound = errors.New("key not found in cache") + var ErrNotInitialized = errors.New("cache not properly initialized") + var ErrPersistFailed = fmt.Errorf("persist to redis failed") + var ErrPullFailed = fmt.Errorf("pull from redis failed") + var ErrRPushFailed = fmt.Errorf("rpush failed") + var ErrTimeout = errors.New("cache operation timed out") + var ErrUnavailable = errors.New("cache service unavailable") + var ErrUnknownPersistMode = fmt.Errorf("unknown persistence mode") + func ClearAllKV(ctx context.Context) error + func GetKVMany[K comparable, V any](ctx context.Context, name string, keys []K) map[K]V + func LockWithRetry(ctx context.Context, client redis.UniversalClient, key string, ...) error + func MutexLock(ctx context.Context, client redis.UniversalClient, key string, ...) error + func NewDefaultCachexLogger() logger.ILogger + func NewRedisOptions(addr, password string, db int) *redis.Options + func PublishJSON[T any](p *PubSub, ctx context.Context, channel string, message T) error + func RefreshAllKV(ctx context.Context) error + func RefreshAndSwapAllKV(ctx context.Context) error + func RegisterKV[K comparable, V any](name string, loader KVLoader[K, V], opts ...KVOption) + func ResetAllModelKVLoadCache() + func ResetModelCacheRegistry() + func ResetModelKVRegistry() + func SetGlobalRedisClient(client redis.UniversalClient) + func SetLogger(l logger.ILogger) + func SimplePublish(client redis.UniversalClient, channel string, message any) error + func SimpleSubscribe(client redis.UniversalClient, channel string, handler MessageHandler) (*PubSub, *Subscriber, error) + func StartAllObjectPools(ctx context.Context) error + func StartAllSchedulers(ctx context.Context) error + func StopAllKV() + func StopAllObjectPools() error + func StopAllSchedulers() error + func ValidateBasicOp(key []byte, initialized, closed bool) error + func ValidateCapacity(current, max int) error + func ValidateClosed(closed bool) error + func ValidateInitialized(initialized bool) error + func ValidateKey(key []byte) error + func ValidateTTL(ttl time.Duration) error + func ValidateValue(value []byte) error + func ValidateWriteOp(key, value []byte, initialized, closed bool) error + func ValidateWriteWithTTLOp(key, value []byte, ttl time.Duration, initialized, closed bool) error + func WarmupAllKV(ctx context.Context) error + func WithCache(ctx context.Context, c *CtxCache) context.Context + type AdvancedCache struct + func NewAdvancedCache[T any](client redis.UniversalClient, config AdvancedCacheConfig) *AdvancedCache[T] + func (c *AdvancedCache[T]) BatchGet(ctx context.Context, keys []string) (map[string]T, error) + func (c *AdvancedCache[T]) BatchSet(ctx context.Context, items map[string]T, ttl ...time.Duration) error + func (c *AdvancedCache[T]) Clear(ctx context.Context, pattern string) error + func (c *AdvancedCache[T]) Close() error + func (c *AdvancedCache[T]) Delete(ctx context.Context, keys ...string) error + func (c *AdvancedCache[T]) Exists(ctx context.Context, keys ...string) (int64, error) + func (c *AdvancedCache[T]) Expire(ctx context.Context, key string, ttl time.Duration) error + func (c *AdvancedCache[T]) Get(ctx context.Context, key string) (T, bool, error) + func (c *AdvancedCache[T]) GetHotKeyManager() *HotKeyManager + func (c *AdvancedCache[T]) GetLockManager() *LockManager + func (c *AdvancedCache[T]) GetMetrics() *CacheMetrics + func (c *AdvancedCache[T]) GetOrSet(ctx context.Context, key string, fn func() (T, error), ttl ...time.Duration) (T, error) + func (c *AdvancedCache[T]) GetQueue() *QueueHandler + func (c *AdvancedCache[T]) Keys(ctx context.Context, pattern string) ([]string, error) + func (c *AdvancedCache[T]) Ping(ctx context.Context) error + func (c *AdvancedCache[T]) ResetMetrics() + func (c *AdvancedCache[T]) Set(ctx context.Context, key string, value T, ttl ...time.Duration) error + func (c *AdvancedCache[T]) TTL(ctx context.Context, key string) (time.Duration, error) + func (c *AdvancedCache[T]) Wrap(key string, fn CacheWrapperFunc[T], ttl ...time.Duration) CacheWrapperFunc[T] + type AdvancedCacheConfig struct + Compression CompressionType + DefaultTTL time.Duration + EnableMetrics bool + Logger logger.ILogger + MinSizeForCompress int + Namespace string + type AlertCallback func(event AlertEvent) + type AlertEvent struct + Length int64 + Level AlertLevel + MaxSize int64 + Message string + QueueKey string + Threshold int64 + Timestamp time.Time + type AlertLevel int + const AlertLevelCritical + const AlertLevelError + const AlertLevelInfo + const AlertLevelWarning + func (a AlertLevel) String() string + type BatchLoader func(ctx context.Context, keys []K) (map[K]V, error) + type CacheAsideOperation struct + func (op *CacheAsideOperation[T]) Read() (T, error) + func (op *CacheAsideOperation[T]) Write(value T) error + type CacheBuilder struct + func NewCacheBuilder(redisClient redis.UniversalClient, namespace string) *CacheBuilder + func (b *CacheBuilder) Build() *SmartCache + func (b *CacheBuilder) OnError(fn func(ctx context.Context, err error)) *CacheBuilder + func (b *CacheBuilder) OnMiss(fn func(ctx context.Context, key string) (interface{}, error)) *CacheBuilder + func (b *CacheBuilder) OnSet(fn func(ctx context.Context, key string, value interface{})) *CacheBuilder + func (b *CacheBuilder) WithCompression(compType CompressionType) *CacheBuilder + func (b *CacheBuilder) WithHotKey() *CacheBuilder + func (b *CacheBuilder) WithKeyPattern(pattern string) *CacheBuilder + func (b *CacheBuilder) WithLock(timeout time.Duration) *CacheBuilder + func (b *CacheBuilder) WithPubSub() *CacheBuilder + func (b *CacheBuilder) WithRefreshThreshold(threshold float64) *CacheBuilder + func (b *CacheBuilder) WithTTL(ttl time.Duration) *CacheBuilder + type CacheDistributedLock struct + EnableWatchdog bool + Expiration time.Duration + Timeout time.Duration + type CacheFunc func(ctx context.Context) (T, error) + func CacheWrapperWithIndex[T any](manager *CacheIndexManager, idxKey string, client redis.UniversalClient, ...) CacheFunc[T] + func CacheWrapper[T any](client redis.UniversalClient, key string, cacheFunc CacheFunc[T], ...) CacheFunc[T] + type CacheIndexManager struct + func NewCacheIndexManager(client redis.UniversalClient) *CacheIndexManager + func (m *CacheIndexManager) DeleteByIndex(ctx context.Context, idxKeys ...string) (int64, error) + func (m *CacheIndexManager) DeleteByKeys(ctx context.Context, keys ...string) error + func (m *CacheIndexManager) GetIndexMembers(ctx context.Context, idxKey string) ([]string, error) + func (m *CacheIndexManager) NewIndexGroup(idxKeys ...string) *IndexGroup + func (m *CacheIndexManager) Register(ctx context.Context, idxKey string, cacheKeys ...string) + type CacheMetrics struct + Compressions int64 + Decompressions int64 + Deletes int64 + Hits int64 + Misses int64 + Sets int64 + TotalSize int64 + type CacheOption func(*CacheOptions) + func Combine(opts ...CacheOption) CacheOption + func Match(cases []Case, defaultOpt ...CacheOption) CacheOption + func When(condition bool, opt CacheOption) CacheOption + func WhenThen(condition bool, thenOpt, elseOpt CacheOption) CacheOption + func WithAsyncUpdate() CacheOption + func WithCachePenetration[T any](defaultValue T) CacheOption + func WithDistributedLock(lock *CacheDistributedLock) CacheOption + func WithForceRefresh(force bool) CacheOption + func WithJitter(percent float64) CacheOption + func WithRetry(times int) CacheOption + func WithTTL(ttl time.Duration) CacheOption + func WithoutCompression() CacheOption + type CacheOptions struct + CacheDistributedLock *CacheDistributedLock + CachePenetration bool + DefaultValue interface{} + ForceRefresh bool + JitterPercent *float64 + RetryOnError bool + RetryTimes int + SkipCompress bool + TTLOverride *time.Duration + UseAsync bool + type CachePattern struct + func NewCachePattern[T any](cache *MultiLevelCache[T]) *CachePattern[T] + func (p *CachePattern[T]) CacheAside(ctx context.Context, key string, dbLoader func() (T, error), ...) *CacheAsideOperation[T] + func (p *CachePattern[T]) ReadThrough(ctx context.Context, key string, dbLoader func() (T, error)) (T, error) + func (p *CachePattern[T]) WriteBehind(ctx context.Context, key string, value T, dbWriter func(T) error) error + func (p *CachePattern[T]) WriteThrough(ctx context.Context, key string, value T, dbWriter func(T) error) error + type CacheStrategy struct + Compression CompressionType + DefaultTTL time.Duration + EnableHotKey bool + EnableLock bool + EnablePubSub bool + KeyPattern string + LockTimeout time.Duration + Namespace string + OnCacheMiss func(ctx context.Context, key string) (interface{}, error) + OnCacheSet func(ctx context.Context, key string, value interface{}) + OnError func(ctx context.Context, err error) + RefreshThreshold float64 + type CacheType string + const CacheExpiring + const CacheLRU + const CacheLRUOptimized + const CacheRedis + const CacheRistretto + type CacheWrapperFunc func(ctx context.Context) (T, error) + type Case struct + Condition bool + Opt CacheOption + func NewCase(condition bool, opt CacheOption) Case + type Client struct + func NewClient(ctx context.Context, cfg *ClientConfig) (*Client, error) + func NewExpiringClient(ctx context.Context, cleanupInterval time.Duration) (*Client, error) + func NewLRUClient(ctx context.Context, capacity int) (*Client, error) + func NewLRUOptimizedClient(ctx context.Context, capacity int) (*Client, error) + func NewRedisClient(ctx context.Context, opts *redis.Options) (*Client, error) + func NewRistrettoClient(ctx context.Context, config *RistrettoConfig) (*Client, error) + func (c *Client) BatchGet(keys [][]byte) ([][]byte, []error) + func (c *Client) BatchGetWithCtx(ctx context.Context, keys [][]byte) ([][]byte, []error) + func (c *Client) Close() error + func (c *Client) Del(key []byte) error + func (c *Client) DelWithCtx(ctx context.Context, key []byte) error + func (c *Client) Get(key []byte) ([]byte, error) + func (c *Client) GetConfig() ClientConfig + func (c *Client) GetOrCompute(key []byte, ttl time.Duration, loader func() ([]byte, error)) ([]byte, error) + func (c *Client) GetOrComputeWithCtx(ctx context.Context, key []byte, ttl time.Duration, ...) ([]byte, error) + func (c *Client) GetTTL(key []byte) (time.Duration, error) + func (c *Client) GetTTLWithCtx(ctx context.Context, key []byte) (time.Duration, error) + func (c *Client) GetWithCtx(ctx context.Context, key []byte) ([]byte, error) + func (c *Client) Set(key, value []byte) error + func (c *Client) SetWithCtx(ctx context.Context, key, value []byte) error + func (c *Client) SetWithTTL(key, value []byte, ttl time.Duration) error + func (c *Client) SetWithTTLAndCtx(ctx context.Context, key, value []byte, ttl time.Duration) error + func (c *Client) Stats() map[string]interface{} + func (c *Client) StatsWithCtx(ctx context.Context) map[string]interface{} + func (c *Client) WithContext(ctx context.Context) context.Context + type ClientConfig struct + Capacity int + CleanupInterval time.Duration + RedisConfig *redis.Options + RistrettoConfig *RistrettoConfig + Type CacheType + type CompressionType string + const CompressionGzip + const CompressionNone + type CtxCache struct + func FromContext(ctx context.Context) *CtxCache + func NewCtxCache(h Handler) *CtxCache + func (c *CtxCache) BatchGet(ctx context.Context, keys [][]byte) ([][]byte, []error) + func (c *CtxCache) Close() error + func (c *CtxCache) Del(ctx context.Context, key []byte) error + func (c *CtxCache) Get(ctx context.Context, key []byte) ([]byte, error) + func (c *CtxCache) GetOrCompute(ctx context.Context, key []byte, ttl time.Duration, ...) ([]byte, error) + func (c *CtxCache) GetTTL(ctx context.Context, key []byte) (time.Duration, error) + func (c *CtxCache) Set(ctx context.Context, key, value []byte) error + func (c *CtxCache) SetWithTTL(ctx context.Context, key, value []byte, ttl time.Duration) error + func (c *CtxCache) Stats() map[string]interface{} + type DataLoader interface + Load func(ctx context.Context) (map[K]V, error) + type DeadLetterQueue interface + Clear func(ctx context.Context, queueKey string) error + GetItems func(ctx context.Context, queueKey string, count int64) ([]T, error) + GetLength func(ctx context.Context, queueKey string) (int64, error) + Push func(ctx context.Context, queueKey string, data T) error + Remove func(ctx context.Context, queueKey string, count int64) error + SetAlertCallback func(callback AlertCallback) + SetAlertThresholds func(warning, error, critical float64) + func NewDeadLetterQueue[T any](queueHandler *QueueHandler, config DeadLetterQueueConfig) DeadLetterQueue[T] + type DeadLetterQueueConfig struct + AlertCallback AlertCallback + CriticalThreshold float64 + ErrorThreshold float64 + MaxSize int64 + WarningThreshold float64 + type DelayConsumerOptions struct + OverrideMaxRetries int + OverrideRetryDelay time.Duration + type DelayQueue struct + func NewDelayQueue[T any](client redis.UniversalClient, config ...DelayQueueConfig) *DelayQueue[T] + func (q *DelayQueue[T]) Cancel(ctx context.Context, queueName, key string) (bool, error) + func (q *DelayQueue[T]) DeadLength(ctx context.Context, queueName string) (int64, error) + func (q *DelayQueue[T]) EnqueueAt(ctx context.Context, queueName string, task *DelayTask[T]) error + func (q *DelayQueue[T]) EnqueueWithDelay(ctx context.Context, queueName string, task *DelayTask[T], delay time.Duration) error + func (q *DelayQueue[T]) GetDeadTasks(ctx context.Context, queueName string, offset, limit int64) ([]*DelayTask[T], error) + func (q *DelayQueue[T]) GetTask(ctx context.Context, queueName, key string) (*DelayTask[T], error) + func (q *DelayQueue[T]) Length(ctx context.Context, queueName string) (int64, error) + func (q *DelayQueue[T]) ProcessingLength(ctx context.Context, queueName string) (int64, error) + func (q *DelayQueue[T]) ReadyLength(ctx context.Context, queueName string) (int64, error) + func (q *DelayQueue[T]) StartConsumer(ctx context.Context, queueName string, ...) error + func (q *DelayQueue[T]) Stop() error + func (q *DelayQueue[T]) StopConsumer(queueName string) + type DelayQueueConfig struct + BatchSize int64 + Concurrency int + Logger logger.ILogger + MaxReadySize int64 + MaxRetries int + Namespace string + Ordered bool + PollInterval time.Duration + RetryDelay time.Duration + VisibilityTimeout time.Duration + func DefaultDelayQueueConfig() DelayQueueConfig + type DelayTask struct + Data T + ExecuteAt time.Time + Key string + RetryCount int + type DistributedLock struct + func NewDistributedLock(client redis.UniversalClient, key string, config LockConfig) *DistributedLock + func (c *DistributedLock) WithLogger(logger logger.ILogger) *DistributedLock + func (l *DistributedLock) Extend(ctx context.Context, ttl time.Duration) error + func (l *DistributedLock) GetStats(ctx context.Context) (*LockStats, error) + func (l *DistributedLock) IsLocked(ctx context.Context) (bool, error) + func (l *DistributedLock) Lock(ctx context.Context) error + func (l *DistributedLock) LockWithTimeout(ctx context.Context, timeout time.Duration) error + func (l *DistributedLock) OnAfterExtend(fn func(ctx context.Context, err error)) *DistributedLock + func (l *DistributedLock) OnBeforeExtend(fn func(ctx context.Context)) *DistributedLock + func (l *DistributedLock) TTL(ctx context.Context) (time.Duration, error) + func (l *DistributedLock) TryLock(ctx context.Context) (bool, error) + func (l *DistributedLock) Unlock(ctx context.Context) error + type DurableChannel struct + func NewDurableChannel[T any](client redis.UniversalClient, config DurableChannelConfig) *DurableChannel[T] + func (dc *DurableChannel[T]) Close() error + func (dc *DurableChannel[T]) GetConfig() DurableChannelConfig + func (dc *DurableChannel[T]) GetQueueKey() string + func (dc *DurableChannel[T]) Len() (int64, error) + func (dc *DurableChannel[T]) MemLen() int + func (dc *DurableChannel[T]) Receive() <-chan T + func (dc *DurableChannel[T]) RedisLen() (int64, error) + func (dc *DurableChannel[T]) Send(ctx context.Context, data T) error + func (dc *DurableChannel[T]) TryReceive(ctx context.Context) (T, bool) + type DurableChannelConfig struct + BufferSize int + CompressionMinSize int + EnableCompression bool + Name string + Namespace string + PersistenceMode PersistMode + PollInterval time.Duration + QueryTimeout time.Duration + RecoveryOnStart bool + TTL time.Duration + WorkerCount int + WorkerID int64 + func DefaultDurableChannelConfig(name string) DurableChannelConfig + type ExpiringHandler struct + func NewExpiringHandler(cleanupInterval time.Duration) *ExpiringHandler + func (h *ExpiringHandler) BatchGet(keys [][]byte) ([][]byte, []error) + func (h *ExpiringHandler) BatchGetWithCtx(ctx context.Context, keys [][]byte) ([][]byte, []error) + func (h *ExpiringHandler) Close() error + func (h *ExpiringHandler) Del(key []byte) error + func (h *ExpiringHandler) DelWithCtx(ctx context.Context, key []byte) error + func (h *ExpiringHandler) Get(key []byte) ([]byte, error) + func (h *ExpiringHandler) GetOrCompute(key []byte, ttl time.Duration, loader func() ([]byte, error)) ([]byte, error) + func (h *ExpiringHandler) GetOrComputeWithCtx(ctx context.Context, key []byte, ttl time.Duration, ...) ([]byte, error) + func (h *ExpiringHandler) GetTTL(key []byte) (time.Duration, error) + func (h *ExpiringHandler) GetTTLWithCtx(ctx context.Context, key []byte) (time.Duration, error) + func (h *ExpiringHandler) GetWithCtx(ctx context.Context, key []byte) ([]byte, error) + func (h *ExpiringHandler) Set(key, value []byte) error + func (h *ExpiringHandler) SetWithCtx(ctx context.Context, key, value []byte) error + func (h *ExpiringHandler) SetWithTTL(key, value []byte, ttl time.Duration) error + func (h *ExpiringHandler) SetWithTTLAndCtx(ctx context.Context, key, value []byte, ttl time.Duration) error + func (h *ExpiringHandler) Stats() map[string]interface{} + type FieldCacheConfig struct + CacheName string + FieldName string + type GenericCacheOption func(*GenericTTLCache[K, V]) + func WithLogger[K comparable, V any](log logger.ILogger) GenericCacheOption[K, V] + func WithPubSub[K comparable, V any](pubsub *PubSub, channel string, codec KeyCodec[K]) GenericCacheOption[K, V] + type GenericTTLCache struct + func NewGenericTTLCache[K comparable, V any](opts ...GenericCacheOption[K, V]) *GenericTTLCache[K, V] + func (c *GenericTTLCache[K, V]) Clear() + func (c *GenericTTLCache[K, V]) Delete(key K) + func (c *GenericTTLCache[K, V]) DeleteLocal(key K) + func (c *GenericTTLCache[K, V]) Invalidate(key K) + func (c *GenericTTLCache[K, V]) Load(key K) (V, bool) + func (c *GenericTTLCache[K, V]) Stop() + func (c *GenericTTLCache[K, V]) Store(key K, value V, ttl time.Duration) + type Handler interface + BatchGet func(keys [][]byte) ([][]byte, []error) + BatchGetWithCtx func(ctx context.Context, keys [][]byte) ([][]byte, []error) + Close func() error + Del func(key []byte) error + DelWithCtx func(ctx context.Context, key []byte) error + Get func(key []byte) ([]byte, error) + GetOrCompute func(key []byte, ttl time.Duration, loader func() ([]byte, error)) ([]byte, error) + GetOrComputeWithCtx func(ctx context.Context, key []byte, ttl time.Duration, ...) ([]byte, error) + GetTTL func(key []byte) (time.Duration, error) + GetTTLWithCtx func(ctx context.Context, key []byte) (time.Duration, error) + GetWithCtx func(ctx context.Context, key []byte) ([]byte, error) + Set func(key, value []byte) error + SetWithCtx func(ctx context.Context, key, value []byte) error + SetWithTTL func(key, value []byte, ttl time.Duration) error + SetWithTTLAndCtx func(ctx context.Context, key, value []byte, ttl time.Duration) error + Stats func() map[string]interface{} + func NewRedisHandler(cfg *redis.Options) (Handler, error) + func NewRedisHandlerSimple(addr, password string, db int) (Handler, error) + type HotKeyCache struct + func NewHotKeyCache[K comparable, V any](client redis.UniversalClient, keyName string, loader DataLoader[K, V], ...) *HotKeyCache[K, V] + func (h *HotKeyCache[K, V]) Clear(ctx context.Context) error + func (h *HotKeyCache[K, V]) Delete(ctx context.Context, key K) error + func (h *HotKeyCache[K, V]) Exists(ctx context.Context, key K) (bool, error) + func (h *HotKeyCache[K, V]) Get(ctx context.Context, key K) (V, bool, error) + func (h *HotKeyCache[K, V]) GetAll(ctx context.Context) (map[K]V, error) + func (h *HotKeyCache[K, V]) GetStats(ctx context.Context) (*HotKeyStats, error) + func (h *HotKeyCache[K, V]) Keys(ctx context.Context) ([]K, error) + func (h *HotKeyCache[K, V]) LoadAll(ctx context.Context) (map[K]V, error) + func (h *HotKeyCache[K, V]) Refresh(ctx context.Context) error + func (h *HotKeyCache[K, V]) SaveToRedis(ctx context.Context) error + func (h *HotKeyCache[K, V]) Set(ctx context.Context, key K, value V) error + func (h *HotKeyCache[K, V]) SetAll(ctx context.Context, data map[K]V) error + func (h *HotKeyCache[K, V]) Size(ctx context.Context) (int, error) + func (h *HotKeyCache[K, V]) Stop() + type HotKeyConfig struct + DefaultTTL time.Duration + EnableAutoRefresh bool + Logger logger.ILogger + MaxLocalCacheSize int + Namespace string + RefreshInterval time.Duration + type HotKeyManager struct + func NewHotKeyManager(client redis.UniversalClient, opts ...HotKeyOption) *HotKeyManager + func (m *HotKeyManager) Get(name string) (interface{}, bool) + func (m *HotKeyManager) GetAllStats(ctx context.Context) (map[string]*HotKeyStats, error) + func (m *HotKeyManager) GetCache(name string) (interface{}, bool) + func (m *HotKeyManager) RefreshAll(ctx context.Context) error + func (m *HotKeyManager) Register(name string, cache interface{}) + func (m *HotKeyManager) RegisterCache(name string, cache interface{}) + func (m *HotKeyManager) StopAll() + type HotKeyOption func(*HotKeyConfig) + func WithHotKeyAutoRefresh(enable bool) HotKeyOption + func WithHotKeyLogger(l logger.ILogger) HotKeyOption + func WithHotKeyMaxLocalCacheSize(n int) HotKeyOption + func WithHotKeyNamespace(ns string) HotKeyOption + func WithHotKeyRefreshInterval(d time.Duration) HotKeyOption + func WithHotKeyTTL(ttl time.Duration) HotKeyOption + type HotKeyStats struct + KeyName string + LastRefreshTime time.Time + LocalCacheSize int + TTL int64 + type IDGenerator struct + OnSequenceInit func() int64 + func NewIDGenerator(redisClient redis.UniversalClient) *IDGenerator + func (g *IDGenerator) ForceResetSequence(ctx context.Context, timePrefix string) error + func (g *IDGenerator) GenerateID(ctx context.Context) (string, error) + func (g *IDGenerator) GenerateIDs(ctx context.Context, n int) ([]string, error) + func (g *IDGenerator) GetCurrentSequence(ctx context.Context) (int64, error) + func (g *IDGenerator) GetIDPrefix() string + func (g *IDGenerator) GetIDSuffix() string + func (g *IDGenerator) GetSeparator() string + func (g *IDGenerator) GetSequenceByTime(ctx context.Context, timePrefix string) (int64, error) + func (g *IDGenerator) ResetSequence(ctx context.Context, timePrefix string) error + func (g *IDGenerator) WithExpire(d time.Duration) *IDGenerator + func (g *IDGenerator) WithIDPrefix(prefix string) *IDGenerator + func (g *IDGenerator) WithIDSuffix(suffix string) *IDGenerator + func (g *IDGenerator) WithKeyPrefix(prefix string) *IDGenerator + func (g *IDGenerator) WithSeparator(sep string) *IDGenerator + func (g *IDGenerator) WithSequenceInitCallback(cb func() int64) *IDGenerator + func (g *IDGenerator) WithSequenceLength(length int) *IDGenerator + func (g *IDGenerator) WithSequenceStart(start int64) *IDGenerator + func (g *IDGenerator) WithTimeFormat(format string) *IDGenerator + type IndexGroup struct + func (g *IndexGroup) AddIndexKeys(keys ...string) + func (g *IndexGroup) Delete(ctx context.Context) (int64, error) + func (g *IndexGroup) IndexKeys() []string + type Int64KeyCodec struct + func (Int64KeyCodec) Decode(data string) (int64, error) + func (Int64KeyCodec) Encode(key int64) string + type IntKeyCodec struct + func (IntKeyCodec) Decode(data string) (int, error) + func (IntKeyCodec) Encode(key int) string + type KVCache struct + func GetKV[K comparable, V any](name string) (*KVCache[K, V], error) + func MustGetKV[K comparable, V any](name string) *KVCache[K, V] + func NewKVCache[K comparable, V any](client redis.UniversalClient, name string, loader KVLoader[K, V], ...) *KVCache[K, V] + func (c *KVCache[K, V]) Clear(ctx context.Context) error + func (c *KVCache[K, V]) Client() redis.UniversalClient + func (c *KVCache[K, V]) Delete(ctx context.Context, key K) error + func (c *KVCache[K, V]) DeleteFromPipe(pipe redis.Pipeliner, key K) + func (c *KVCache[K, V]) DeleteMany(ctx context.Context, keys []K) error + func (c *KVCache[K, V]) Get(ctx context.Context, key K) (V, bool, error) + func (c *KVCache[K, V]) GetLastRefreshTime() time.Time + func (c *KVCache[K, V]) GetMany(ctx context.Context, keys []K) (map[K]V, error) + func (c *KVCache[K, V]) GetManyToPipe(pipe redis.Pipeliner, keys []K) *redis.SliceCmd + func (c *KVCache[K, V]) LoadAll(ctx context.Context) (map[K]V, error) + func (c *KVCache[K, V]) Name() string + func (c *KVCache[K, V]) PublishInvalidation(keys []string) + func (c *KVCache[K, V]) Refresh(ctx context.Context) error + func (c *KVCache[K, V]) RefreshAndSwap(ctx context.Context) error + func (c *KVCache[K, V]) Set(ctx context.Context, key K, value V) error + func (c *KVCache[K, V]) SetMany(ctx context.Context, items map[K]V) error + func (c *KVCache[K, V]) SetToPipe(pipe redis.Pipeliner, key K, value V) error + func (c *KVCache[K, V]) Size() int + func (c *KVCache[K, V]) Stop() + type KVCacheConfig struct + BatchLoader any + DefaultTTL time.Duration + EnableAutoRefresh bool + Logger logger.ILogger + MaxLocalCacheSize int + Namespace string + RefreshInterval time.Duration + type KVLoader func(ctx context.Context) (map[K]V, error) + type KVOption func(*KVCacheConfig) + func WithKVAutoRefresh(enable bool) KVOption + func WithKVBatchLoader[K comparable, V any](loader BatchLoader[K, V]) KVOption + func WithKVLogger(l logger.ILogger) KVOption + func WithKVMaxLocalCacheSize(n int) KVOption + func WithKVNamespace(ns string) KVOption + func WithKVRefreshInterval(d time.Duration) KVOption + func WithKVTTL(ttl time.Duration) KVOption + type KeyCodec interface + Decode func(data string) (K, error) + Encode func(key K) string + type LRUHandler struct + func NewLRUHandler(maxEntries int) *LRUHandler + func (h *LRUHandler) BatchGet(keys [][]byte) ([][]byte, []error) + func (h *LRUHandler) BatchGetWithCtx(ctx context.Context, keys [][]byte) ([][]byte, []error) + func (h *LRUHandler) Close() error + func (h *LRUHandler) Del(key []byte) error + func (h *LRUHandler) DelWithCtx(ctx context.Context, key []byte) error + func (h *LRUHandler) Get(key []byte) ([]byte, error) + func (h *LRUHandler) GetOrCompute(key []byte, ttl time.Duration, loader func() ([]byte, error)) ([]byte, error) + func (h *LRUHandler) GetOrComputeWithCtx(ctx context.Context, key []byte, ttl time.Duration, ...) ([]byte, error) + func (h *LRUHandler) GetTTL(key []byte) (time.Duration, error) + func (h *LRUHandler) GetTTLWithCtx(ctx context.Context, key []byte) (time.Duration, error) + func (h *LRUHandler) GetWithCtx(ctx context.Context, key []byte) ([]byte, error) + func (h *LRUHandler) Set(key, value []byte) error + func (h *LRUHandler) SetWithCtx(ctx context.Context, key, value []byte) error + func (h *LRUHandler) SetWithTTL(key, value []byte, ttl time.Duration) error + func (h *LRUHandler) SetWithTTLAndCtx(ctx context.Context, key, value []byte, ttl time.Duration) error + func (h *LRUHandler) Stats() map[string]interface{} + type LRUOptimizedHandler struct + func NewLRUOptimizedHandler(maxEntries int) *LRUOptimizedHandler + func (h *LRUOptimizedHandler) BatchGet(keys [][]byte) ([][]byte, []error) + func (h *LRUOptimizedHandler) BatchGetWithCtx(ctx context.Context, keys [][]byte) ([][]byte, []error) + func (h *LRUOptimizedHandler) Clear() + func (h *LRUOptimizedHandler) Close() error + func (h *LRUOptimizedHandler) Del(key []byte) error + func (h *LRUOptimizedHandler) DelWithCtx(ctx context.Context, key []byte) error + func (h *LRUOptimizedHandler) Get(key []byte) ([]byte, error) + func (h *LRUOptimizedHandler) GetOrCompute(key []byte, ttl time.Duration, loader func() ([]byte, error)) ([]byte, error) + func (h *LRUOptimizedHandler) GetOrComputeWithCtx(ctx context.Context, key []byte, ttl time.Duration, ...) ([]byte, error) + func (h *LRUOptimizedHandler) GetTTL(key []byte) (time.Duration, error) + func (h *LRUOptimizedHandler) GetTTLWithCtx(ctx context.Context, key []byte) (time.Duration, error) + func (h *LRUOptimizedHandler) GetWithCtx(ctx context.Context, key []byte) ([]byte, error) + func (h *LRUOptimizedHandler) Set(key, value []byte) error + func (h *LRUOptimizedHandler) SetWithCtx(ctx context.Context, key, value []byte) error + func (h *LRUOptimizedHandler) SetWithTTL(key, value []byte, ttl time.Duration) error + func (h *LRUOptimizedHandler) SetWithTTLAndCtx(ctx context.Context, key, value []byte, ttl time.Duration) error + func (h *LRUOptimizedHandler) Stats() map[string]interface{} + type LockConfig struct + EnableWatchdog bool + Logger logger.ILogger + MaxRetries int + Namespace string + RetryInterval time.Duration + TTL time.Duration + WatchdogInterval time.Duration + type LockManager struct + func NewLockManager(client redis.UniversalClient, opts ...LockOption) *LockManager + func (m *LockManager) CleanupExpiredLocks(ctx context.Context) error + func (m *LockManager) GetAllLockStats(ctx context.Context) (map[string]*LockStats, error) + func (m *LockManager) GetLock(key string) *DistributedLock + func (m *LockManager) ReleaseAllLocks(ctx context.Context) error + func (m *LockManager) ReleaseLock(ctx context.Context, key string) error + type LockOption func(*LockConfig) + func WithLockLogger(l logger.ILogger) LockOption + func WithLockMaxRetries(n int) LockOption + func WithLockNamespace(ns string) LockOption + func WithLockRetryInterval(d time.Duration) LockOption + func WithLockTTL(ttl time.Duration) LockOption + func WithLockWatchdog(enable bool) LockOption + func WithLockWatchdogInterval(d time.Duration) LockOption + type LockStats struct + Acquired bool + ExpireTime time.Time + Key string + TTL time.Duration + Token string + WatchdogActive bool + type MessageHandler func(ctx context.Context, channel string, message string) error + type ModelCache struct + func GetModelCache[M any]() (*ModelCache[M], error) + func MustGetModelCache[M any]() *ModelCache[M] + func (c *ModelCache[M]) Delete(ctx context.Context, m *M) error + func (c *ModelCache[M]) DeleteByKey(ctx context.Context, keyValues ...string) error + func (c *ModelCache[M]) Get(ctx context.Context, keyValues ...string) (M, bool, error) + func (c *ModelCache[M]) InvalidateAll(ctx context.Context) error + func (c *ModelCache[M]) Set(ctx context.Context, m *M) error + func (c *ModelCache[M]) TableName() string + type ModelCacheBuilder struct + func NewModelCache[M any](base *ModelKVBase, db *gorm.DB) *ModelCacheBuilder[M] + func (b *ModelCacheBuilder[M]) ExtraOptions(opts ...KVOption) *ModelCacheBuilder[M] + func (b *ModelCacheBuilder[M]) KeyFields(names ...string) *ModelCacheBuilder[M] + func (b *ModelCacheBuilder[M]) Register() *ModelCache[M] + func (b *ModelCacheBuilder[M]) Separator(sep string) *ModelCacheBuilder[M] + type ModelKVBase struct + func NewModelKVBase() *ModelKVBase + func (b *ModelKVBase) Namespace(ns string) *ModelKVBase + func (b *ModelKVBase) Options(opts ...KVOption) *ModelKVBase + func (b *ModelKVBase) RefreshInterval(d time.Duration) *ModelKVBase + func (b *ModelKVBase) TTL(ttl time.Duration) *ModelKVBase + type ModelKVBuilder struct + func NewModelKV[M any](base *ModelKVBase, db *gorm.DB) *ModelKVBuilder[M] + func (b *ModelKVBuilder[M]) ExtraOptions(opts ...KVOption) *ModelKVBuilder[M] + func (b *ModelKVBuilder[M]) Field(fieldName string) *ModelKVBuilder[M] + func (b *ModelKVBuilder[M]) Fields(fieldNames ...string) *ModelKVBuilder[M] + func (b *ModelKVBuilder[M]) KeyField(name string) *ModelKVBuilder[M] + func (b *ModelKVBuilder[M]) LoadTTL(ttl time.Duration) *ModelKVBuilder[M] + func (b *ModelKVBuilder[M]) Register() *ModelKVCache[M] + type ModelKVCache struct + func GetModelKV[M any]() (*ModelKVCache[M], error) + func MustGetModelKV[M any]() *ModelKVCache[M] + func (c *ModelKVCache[M]) Delete(ctx context.Context, m *M) error + func (c *ModelKVCache[M]) DeleteByKey(ctx context.Context, key string) error + func (c *ModelKVCache[M]) GetFieldMany(ctx context.Context, fieldName string, keys []string) map[string]string + func (c *ModelKVCache[M]) GetFieldsMany(ctx context.Context, fieldNames, keys []string) map[string]map[string]string + func (c *ModelKVCache[M]) ResetLoadCache() + func (c *ModelKVCache[M]) Set(ctx context.Context, m *M) error + type MultiLevelCache struct + func NewMultiLevelCache[T any](redisClient redis.UniversalClient, config MultiLevelConfig) *MultiLevelCache[T] + func (m *MultiLevelCache[T]) Clear(ctx context.Context) error + func (m *MultiLevelCache[T]) Delete(ctx context.Context, key string) error + func (m *MultiLevelCache[T]) Get(ctx context.Context, key string, loader func() (T, error)) (T, error) + func (m *MultiLevelCache[T]) GetStats() map[string]int64 + func (m *MultiLevelCache[T]) InvalidateL1(key string) + func (m *MultiLevelCache[T]) Set(ctx context.Context, key string, value T) error + type MultiLevelConfig struct + EnableCompression bool + L1Size int + L1TTL time.Duration + L2TTL time.Duration + Namespace string + SyncInterval time.Duration + type ObjectPool interface + Name func() string + Start func(ctx context.Context) error + Stop func() error + type ObjectPoolConfig struct + BatchSize int + Capacity int + ColdStartCount int + Logger logger.ILogger + MinThreshold int + RefreshInterval time.Duration + type ObjectPoolManager struct + func GetObjectPool[T any](name string) (*ObjectPoolManager[T], error) + func MustGetObjectPool[T any](name string) *ObjectPoolManager[T] + func RegisterObjectPool[T any](name string, factory PoolFactory[T], opts ...ObjectPoolOption) *ObjectPoolManager[T] + func (m *ObjectPoolManager[T]) Len() int + func (m *ObjectPoolManager[T]) Name() string + func (m *ObjectPoolManager[T]) Start(ctx context.Context) error + func (m *ObjectPoolManager[T]) Stats() PoolStats + func (m *ObjectPoolManager[T]) Stop() error + func (m *ObjectPoolManager[T]) TryGet() (T, bool) + type ObjectPoolOption func(*ObjectPoolConfig) + func WithObjectPoolBatchSize(n int) ObjectPoolOption + func WithObjectPoolCapacity(n int) ObjectPoolOption + func WithObjectPoolColdStartCount(n int) ObjectPoolOption + func WithObjectPoolLogger(l logger.ILogger) ObjectPoolOption + func WithObjectPoolMinThreshold(n int) ObjectPoolOption + func WithObjectPoolRefreshInterval(d time.Duration) ObjectPoolOption + type PersistMode int + const PersistAsync + const PersistHybrid + const PersistSync + func (pm PersistMode) String() string + type PoolFactory func() (T, error) + type PoolStats struct + Available int + Capacity int + Generated int64 + Name string + Served int64 + type PubSub struct + func NewPubSub(client redis.UniversalClient, opts ...PubSubOption) *PubSub + func (p *PubSub) BroadcastMessage(ctx context.Context, channels []string, message any) error + func (p *PubSub) Close() error + func (p *PubSub) GetChannels() []string + func (p *PubSub) GetClient() redis.UniversalClient + func (p *PubSub) GetStats() *PubSubStats + func (p *PubSub) GetSubscribers() int + func (p *PubSub) Publish(ctx context.Context, channel string, message any) error + func (p *PubSub) RequestResponse(ctx context.Context, requestChannel, responseChannel string, request any, ...) (string, error) + func (p *PubSub) ResolveChannel(channel string) string + func (p *PubSub) Subscribe(channels []string, handler MessageHandler) (*Subscriber, error) + func (p *PubSub) SubscribePattern(patterns []string, handler MessageHandler) (*Subscriber, error) + func (p *PubSub) Unsubscribe(channels ...string) error + type PubSubConfig struct + BufferSize int + CompressionMinSize int + EnableCompression bool + Logger logger.ILogger + MaxRetries int + MaxWorkers int + Namespace string + PingInterval time.Duration + RetryDelay time.Duration + StartRetryWindow time.Duration + WorkerQueueSize int + func DefaultPubSubConfig() PubSubConfig + type PubSubOption func(*PubSubConfig) + func WithPubSubBufferSize(n int) PubSubOption + func WithPubSubCompression(enable bool) PubSubOption + func WithPubSubCompressionMinSize(n int) PubSubOption + func WithPubSubLogger(l logger.ILogger) PubSubOption + func WithPubSubMaxRetries(n int) PubSubOption + func WithPubSubMaxWorkers(n int) PubSubOption + func WithPubSubNamespace(ns string) PubSubOption + func WithPubSubPingInterval(d time.Duration) PubSubOption + func WithPubSubRetryDelay(d time.Duration) PubSubOption + func WithPubSubStartRetryWindow(d time.Duration) PubSubOption + func WithPubSubWorkerQueueSize(n int) PubSubOption + type PubSubStats struct + ActiveSubscribers int + Channels []string + Patterns []string + type QueueConfig struct + BatchSize int + CleanupInterval time.Duration + EnableDistributedLock bool + LockTimeout time.Duration + MaxRetries int + RetryDelay time.Duration + type QueueHandler struct + func NewQueueHandler(client redis.UniversalClient, namespace string, config QueueConfig) *QueueHandler + func (q *QueueHandler) AcquireLock(ctx context.Context, queueName string, workerID string) (bool, error) + func (q *QueueHandler) BatchDequeue(ctx context.Context, queueName string, queueType QueueType, count int) ([]*QueueItem, error) + func (q *QueueHandler) Clear(ctx context.Context, queueName string, queueType QueueType) error + func (q *QueueHandler) Contains(ctx context.Context, queueName string, queueType QueueType, itemID string) (bool, error) + func (q *QueueHandler) Dequeue(ctx context.Context, queueName string, queueType QueueType) (*QueueItem, error) + func (q *QueueHandler) DequeueNonBlocking(ctx context.Context, queueName string, queueType QueueType) (*QueueItem, error) + func (q *QueueHandler) Enqueue(ctx context.Context, queueName string, queueType QueueType, item *QueueItem) error + func (q *QueueHandler) GetFailedItems(ctx context.Context, queueName string, offset, limit int64) ([]*QueueItem, error) + func (q *QueueHandler) GetStats(ctx context.Context, queueName string, queueType QueueType) (*QueueStats, error) + func (q *QueueHandler) Length(ctx context.Context, queueName string, queueType QueueType) (int64, error) + func (q *QueueHandler) Peek(ctx context.Context, queueName string, queueType QueueType, count int) ([]*QueueItem, error) + func (q *QueueHandler) ReleaseLock(ctx context.Context, queueName string, workerID string) error + func (q *QueueHandler) RetryFailed(ctx context.Context, queueName string, queueType QueueType, item *QueueItem) error + type QueueItem struct + CreatedAt int64 + Data interface{} + DelayTime int64 + ID string + Priority float64 + RetryCount int + type QueueStats struct + DelayedCount int64 + FailedCount int64 + Length int64 + QueueName string + QueueType string + type QueueType string + const QueueTypeDelayed + const QueueTypeFIFO + const QueueTypeLIFO + const QueueTypePriority + type RedisHandler struct + func (h *RedisHandler) BatchGet(keys [][]byte) ([][]byte, []error) + func (h *RedisHandler) BatchGetWithCtx(ctx context.Context, keys [][]byte) ([][]byte, []error) + func (h *RedisHandler) Close() error + func (h *RedisHandler) Del(k []byte) error + func (h *RedisHandler) DelWithCtx(ctx context.Context, k []byte) error + func (h *RedisHandler) Get(k []byte) ([]byte, error) + func (h *RedisHandler) GetOrCompute(key []byte, ttl time.Duration, loader func() ([]byte, error)) ([]byte, error) + func (h *RedisHandler) GetOrComputeWithCtx(ctx context.Context, key []byte, ttl time.Duration, ...) ([]byte, error) + func (h *RedisHandler) GetTTL(k []byte) (time.Duration, error) + func (h *RedisHandler) GetTTLWithCtx(ctx context.Context, k []byte) (time.Duration, error) + func (h *RedisHandler) GetWithCtx(ctx context.Context, k []byte) ([]byte, error) + func (h *RedisHandler) Set(k, v []byte) error + func (h *RedisHandler) SetWithCtx(ctx context.Context, k, v []byte) error + func (h *RedisHandler) SetWithTTL(k, v []byte, ttl time.Duration) error + func (h *RedisHandler) SetWithTTLAndCtx(ctx context.Context, k, v []byte, ttl time.Duration) error + func (h *RedisHandler) Stats() map[string]interface{} + func (h *RedisHandler) WithCtx(ctx context.Context) *RedisHandler + type RistrettoConfig struct + AsyncWrites bool + BufferItems int64 + Cost func(value []byte) int64 + IgnoreInternalCost bool + KeyToHash func(key []byte) (uint64, uint64) + MaxCost int64 + Metrics bool + NumCounters int64 + OnEvict func(item *ristretto.Item[[]byte]) + OnExit func(val []byte) + OnReject func(item *ristretto.Item[[]byte]) + ShouldUpdate func(cur, prev []byte) bool + TtlTickerDurationInSec int64 + func NewDefaultRistrettoConfig() *RistrettoConfig + func (c *RistrettoConfig) EnableMetrics() *RistrettoConfig + func (c *RistrettoConfig) SetBufferItems(bufferItems int64) *RistrettoConfig + func (c *RistrettoConfig) SetCost(fn func(value []byte) int64) *RistrettoConfig + func (c *RistrettoConfig) SetIgnoreInternalCost(ignore bool) *RistrettoConfig + func (c *RistrettoConfig) SetKeyToHash(fn func(key []byte) (uint64, uint64)) *RistrettoConfig + func (c *RistrettoConfig) SetMaxCost(maxCost int64) *RistrettoConfig + func (c *RistrettoConfig) SetNumCounters(numCounters int64) *RistrettoConfig + func (c *RistrettoConfig) SetOnEvict(fn func(item *ristretto.Item[[]byte])) *RistrettoConfig + func (c *RistrettoConfig) SetOnExit(fn func(val []byte)) *RistrettoConfig + func (c *RistrettoConfig) SetOnReject(fn func(item *ristretto.Item[[]byte])) *RistrettoConfig + func (c *RistrettoConfig) SetShouldUpdate(fn func(cur, prev []byte) bool) *RistrettoConfig + func (c *RistrettoConfig) SetTtlTickerDurationInSec(duration int64) *RistrettoConfig + type RistrettoHandler struct + func NewDefaultRistrettoHandler() (*RistrettoHandler, error) + func NewRistrettoHandler(config *RistrettoConfig) (*RistrettoHandler, error) + func (h *RistrettoHandler) BatchGet(keys [][]byte) ([][]byte, []error) + func (h *RistrettoHandler) BatchGetWithCtx(ctx context.Context, keys [][]byte) ([][]byte, []error) + func (h *RistrettoHandler) Close() error + func (h *RistrettoHandler) Del(k []byte) error + func (h *RistrettoHandler) DelWithCtx(ctx context.Context, k []byte) error + func (h *RistrettoHandler) Get(k []byte) ([]byte, error) + func (h *RistrettoHandler) GetOrCompute(key []byte, ttl time.Duration, loader func() ([]byte, error)) ([]byte, error) + func (h *RistrettoHandler) GetOrComputeWithCtx(ctx context.Context, key []byte, ttl time.Duration, ...) ([]byte, error) + func (h *RistrettoHandler) GetTTL(k []byte) (time.Duration, error) + func (h *RistrettoHandler) GetTTLWithCtx(ctx context.Context, k []byte) (time.Duration, error) + func (h *RistrettoHandler) GetWithCtx(ctx context.Context, k []byte) ([]byte, error) + func (h *RistrettoHandler) Set(k, v []byte) error + func (h *RistrettoHandler) SetWithCtx(ctx context.Context, k, v []byte) error + func (h *RistrettoHandler) SetWithTTL(k, v []byte, ttl time.Duration) error + func (h *RistrettoHandler) SetWithTTLAndCtx(ctx context.Context, k, v []byte, ttl time.Duration) error + func (h *RistrettoHandler) Stats() map[string]interface{} + type SQLDataLoader struct + QueryFunc func(ctx context.Context) (map[K]V, error) + func (s *SQLDataLoader[K, V]) Load(ctx context.Context) (map[K]V, error) + type Scheduler interface + Name func() string + Start func(ctx context.Context) error + Stop func() error + type SchedulerConfig struct + BatchSize int64 + Concurrency int + MaxReadySize int64 + MaxRetries int + Namespace string + Ordered bool + PollInterval time.Duration + QueueName string + RetryDelay time.Duration + VisibilityTimeout time.Duration + type SchedulerHandler func(ctx context.Context, task *DelayTask[T]) error + type SchedulerManager struct + func GetScheduler[T any](name string) (*SchedulerManager[T], error) + func MustGetScheduler[T any](name string) *SchedulerManager[T] + func RegisterScheduler[T any](name string, handler SchedulerHandler[T], opts ...SchedulerOption) *SchedulerManager[T] + func (m *SchedulerManager[T]) Cancel(ctx context.Context, key string) (bool, error) + func (m *SchedulerManager[T]) DeadLength(ctx context.Context) (int64, error) + func (m *SchedulerManager[T]) EnqueueAt(ctx context.Context, task *DelayTask[T]) error + func (m *SchedulerManager[T]) EnqueueWithDelay(ctx context.Context, task *DelayTask[T], delay time.Duration) error + func (m *SchedulerManager[T]) GetDeadTasks(ctx context.Context, offset, limit int64) ([]*DelayTask[T], error) + func (m *SchedulerManager[T]) GetTask(ctx context.Context, key string) (*DelayTask[T], error) + func (m *SchedulerManager[T]) Length(ctx context.Context) (int64, error) + func (m *SchedulerManager[T]) Name() string + func (m *SchedulerManager[T]) Start(ctx context.Context) error + func (m *SchedulerManager[T]) Stop() error + type SchedulerOption func(*SchedulerConfig) + func WithSchedulerBatchSize(n int64) SchedulerOption + func WithSchedulerConcurrency(n int) SchedulerOption + func WithSchedulerMaxReadySize(n int64) SchedulerOption + func WithSchedulerMaxRetries(n int) SchedulerOption + func WithSchedulerNamespace(ns string) SchedulerOption + func WithSchedulerOrdered() SchedulerOption + func WithSchedulerPollInterval(d time.Duration) SchedulerOption + func WithSchedulerQueueName(name string) SchedulerOption + func WithSchedulerRetryDelay(d time.Duration) SchedulerOption + func WithSchedulerVisibilityTimeout(d time.Duration) SchedulerOption + type ShardedHandler struct + func NewShardedHandler(factory func() Handler, shards int) *ShardedHandler + func (h *ShardedHandler) BatchGet(keys [][]byte) ([][]byte, []error) + func (h *ShardedHandler) BatchGetWithCtx(ctx context.Context, keys [][]byte) ([][]byte, []error) + func (h *ShardedHandler) Close() error + func (h *ShardedHandler) Del(key []byte) error + func (h *ShardedHandler) DelWithCtx(ctx context.Context, key []byte) error + func (h *ShardedHandler) Get(key []byte) ([]byte, error) + func (h *ShardedHandler) GetOrCompute(key []byte, ttl time.Duration, loader func() ([]byte, error)) ([]byte, error) + func (h *ShardedHandler) GetOrComputeWithCtx(ctx context.Context, key []byte, ttl time.Duration, ...) ([]byte, error) + func (h *ShardedHandler) GetTTL(key []byte) (time.Duration, error) + func (h *ShardedHandler) GetTTLWithCtx(ctx context.Context, key []byte) (time.Duration, error) + func (h *ShardedHandler) GetWithCtx(ctx context.Context, key []byte) ([]byte, error) + func (h *ShardedHandler) Set(key, value []byte) error + func (h *ShardedHandler) SetWithCtx(ctx context.Context, key, value []byte) error + func (h *ShardedHandler) SetWithTTL(key, value []byte, ttl time.Duration) error + func (h *ShardedHandler) SetWithTTLAndCtx(ctx context.Context, key, value []byte, ttl time.Duration) error + func (h *ShardedHandler) Stats() map[string]interface{} + type SmartCache struct + func (c *SmartCache) Close() error + func (c *SmartCache) Delete(ctx context.Context, key string) error + func (c *SmartCache) Get(ctx context.Context, key string) (interface{}, error) + func (c *SmartCache) GetOrSet(ctx context.Context, key string, loader func() (interface{}, error)) (interface{}, error) + func (c *SmartCache) Set(ctx context.Context, key string, value interface{}, ttl ...time.Duration) error + func (c *SmartCache) Subscribe(ctx context.Context, event string, handler func(data interface{})) (*Subscriber, error) + type StringKeyCodec struct + func (StringKeyCodec) Decode(data string) (string, error) + func (StringKeyCodec) Encode(key string) string + type Subscriber struct + func SubscribeJSON[T any](p *PubSub, channels []string, handler TypedMessageHandler[T]) (*Subscriber, error) + func (s *Subscriber) GetChannels() []string + func (s *Subscriber) GetSubscriptionInfo() *SubscriptionInfo + func (s *Subscriber) IsActive() bool + func (s *Subscriber) Resubscribe() error + func (s *Subscriber) Stop() + func (s *Subscriber) Unsubscribe() error + type SubscriptionInfo struct + ChannelCount int + Channels []string + Config PubSubConfig + IsActive bool + IsPattern bool + type TwoLevelHandler struct + L1 Handler + L2 Handler + WriteThrough bool + func NewTwoLevelHandler(l1, l2 Handler, writeThrough bool) *TwoLevelHandler + func (h *TwoLevelHandler) BatchGet(keys [][]byte) ([][]byte, []error) + func (h *TwoLevelHandler) BatchGetWithCtx(ctx context.Context, keys [][]byte) ([][]byte, []error) + func (h *TwoLevelHandler) Close() error + func (h *TwoLevelHandler) Del(key []byte) error + func (h *TwoLevelHandler) DelWithCtx(ctx context.Context, key []byte) error + func (h *TwoLevelHandler) Get(key []byte) ([]byte, error) + func (h *TwoLevelHandler) GetOrCompute(key []byte, ttl time.Duration, loader func() ([]byte, error)) ([]byte, error) + func (h *TwoLevelHandler) GetOrComputeWithCtx(ctx context.Context, key []byte, ttl time.Duration, ...) ([]byte, error) + func (h *TwoLevelHandler) GetTTL(key []byte) (time.Duration, error) + func (h *TwoLevelHandler) GetTTLWithCtx(ctx context.Context, key []byte) (time.Duration, error) + func (h *TwoLevelHandler) GetWithCtx(ctx context.Context, key []byte) ([]byte, error) + func (h *TwoLevelHandler) Set(key, value []byte) error + func (h *TwoLevelHandler) SetWithCtx(ctx context.Context, key, value []byte) error + func (h *TwoLevelHandler) SetWithTTL(key, value []byte, ttl time.Duration) error + func (h *TwoLevelHandler) SetWithTTLAndCtx(ctx context.Context, key, value []byte, ttl time.Duration) error + func (h *TwoLevelHandler) Stats() map[string]interface{} + type TypedMessageHandler func(ctx context.Context, channel string, message T) error + type Uint64KeyCodec struct + func (Uint64KeyCodec) Decode(data string) (uint64, error) + func (Uint64KeyCodec) Encode(key uint64) string + type VersionTracker struct + func NewVersionTracker(redisClient redis.UniversalClient, prefix string) *VersionTracker + func (v *VersionTracker) BatchUpdateVersion(ctx context.Context, resourceIDs []string, version int64) error + func (v *VersionTracker) BatchUpdateVersionWithNow(ctx context.Context, resourceIDs []string) error + func (v *VersionTracker) DeleteVersion(ctx context.Context, resourceID string) error + func (v *VersionTracker) DeleteVersions(ctx context.Context, resourceIDs []string) error + func (v *VersionTracker) GetOrCreateVersion(ctx context.Context, resourceID string) (int64, error) + func (v *VersionTracker) GetVersion(ctx context.Context, resourceID string) (int64, error) + func (v *VersionTracker) GetVersionKey(resourceID string) string + func (v *VersionTracker) HasChanged(ctx context.Context, resourceID string, lastVersion int64) (bool, int64) + func (v *VersionTracker) Touch(ctx context.Context, resourceID string) error + func (v *VersionTracker) TouchAll(ctx context.Context, resourceIDs []string) error + func (v *VersionTracker) UpdateVersion(ctx context.Context, resourceID string, version int64) error + func (v *VersionTracker) UpdateVersionWithNow(ctx context.Context, resourceID string) error