Versions in this module Expand all Collapse all v1 v1.0.0 Feb 3, 2026 Changes in this version + func GetJSON(ctx context.Context, c Cache, key string, v interface{}) error + func SetJSON(ctx context.Context, c Cache, key string, v interface{}, ttl time.Duration) error + type Cache interface + Clear func(ctx context.Context, pattern string) error + Close func() error + Delete func(ctx context.Context, key string) error + Exists func(ctx context.Context, key string) (bool, error) + Get func(ctx context.Context, key string) ([]byte, error) + Ping func(ctx context.Context) error + Set func(ctx context.Context, key string, value []byte, ttl time.Duration) error + Stats func(ctx context.Context) (*Stats, error) + func New(cfg *Config) (Cache, error) + type Config struct + Cluster bool + ClusterNodes []string + DB int + Host string + MaxSize int + MinIdle int + Password string + PoolSize int + Port int + Prefix string + TTL int + Timeout time.Duration + Type string + URL string + func DefaultConfig() *Config + type MemoryCache struct + func NewMemoryCache(maxSize int, defaultTTL time.Duration) *MemoryCache + func (c *MemoryCache) Clear(ctx context.Context, pattern string) error + func (c *MemoryCache) Close() error + func (c *MemoryCache) Delete(ctx context.Context, key string) error + func (c *MemoryCache) Exists(ctx context.Context, key string) (bool, error) + func (c *MemoryCache) Get(ctx context.Context, key string) ([]byte, error) + func (c *MemoryCache) Ping(ctx context.Context) error + func (c *MemoryCache) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error + func (c *MemoryCache) Stats(ctx context.Context) (*Stats, error) + type RedisCache struct + func NewRedisCache(cfg *RedisConfig) (*RedisCache, error) + func (c *RedisCache) Clear(ctx context.Context, pattern string) error + func (c *RedisCache) Close() error + func (c *RedisCache) Delete(ctx context.Context, key string) error + func (c *RedisCache) Exists(ctx context.Context, key string) (bool, error) + func (c *RedisCache) Expire(ctx context.Context, key string, ttl time.Duration) error + func (c *RedisCache) Get(ctx context.Context, key string) ([]byte, error) + func (c *RedisCache) HGet(ctx context.Context, key, field string) ([]byte, error) + func (c *RedisCache) HGetAll(ctx context.Context, key string) (map[string]string, error) + func (c *RedisCache) HSet(ctx context.Context, key, field string, value []byte) error + func (c *RedisCache) Incr(ctx context.Context, key string) (int64, error) + func (c *RedisCache) Ping(ctx context.Context) error + func (c *RedisCache) Publish(ctx context.Context, channel string, message []byte) error + func (c *RedisCache) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error + func (c *RedisCache) SetNX(ctx context.Context, key string, value []byte, ttl time.Duration) (bool, error) + func (c *RedisCache) Stats(ctx context.Context) (*Stats, error) + func (c *RedisCache) Subscribe(ctx context.Context, channel string) *redis.PubSub + type RedisConfig struct + Cluster bool + ClusterNodes []string + DB int + Host string + MinIdle int + Password string + PoolSize int + Port int + Prefix string + Timeout time.Duration + Type string + URL string + type Stats struct + Backend string + Connected bool + Hits int64 + Keys int64 + MemoryUsed int64 + Misses int64