Versions in this module Expand all Collapse all v1 v1.0.0 Jul 20, 2026 Changes in this version + var DefaultTTL = TTL + var ErrCacheSetFailed = errors.New("cache set operation failed") + var Forever = TTL + func NewRedisClient(ctx context.Context, options ...RedisClientOption) (*redis.Client, error) + type Cache struct + func NewCache[Value any](driver Driver[Value]) *Cache[Value] + func NewMemoryCache[Value any](options ...MemoryOption) *Cache[Value] + func NewRedisCache[Value any](client *redis.Client, options ...RedisDriverOption) *Cache[Value] + func (c *Cache[Value]) Delete(ctx context.Context, key Key) error + func (c *Cache[Value]) Driver() Driver[Value] + func (c *Cache[Value]) Get(ctx context.Context, key Key) (Value, bool, error) + func (c *Cache[Value]) Has(ctx context.Context, key Key) (bool, error) + func (c *Cache[Value]) Remember(ctx context.Context, key Key, ttl TTL, ...) (Value, error) + func (c *Cache[Value]) Set(ctx context.Context, key Key, value Value, ttl TTL) error + type Cacher interface + Delete func(ctx context.Context, key Key) error + Get func(ctx context.Context, key Key) (value Value, found bool, err error) + Has func(ctx context.Context, key Key) (bool, error) + Remember func(ctx context.Context, key Key, ttl TTL, ...) (Value, error) + Set func(ctx context.Context, key Key, value Value, ttl TTL) error + type Driver interface + Delete func(ctx context.Context, key Key) error + Get func(ctx context.Context, key Key) (value Value, found bool, err error) + Has func(ctx context.Context, key Key) (bool, error) + Set func(ctx context.Context, key Key, value Value, ttl TTL) error + type Hit struct + Expiry time.Time + Value Value + type Key string + type MemoryConfig struct + DefaultTTL time.Duration + type MemoryDriver struct + func NewMemoryDriver[Value any](options ...MemoryOption) *MemoryDriver[Value] + func (d *MemoryDriver[Value]) Delete(_ context.Context, key Key) error + func (d *MemoryDriver[Value]) Get(_ context.Context, key Key) (Value, bool, error) + func (d *MemoryDriver[Value]) Has(ctx context.Context, key Key) (bool, error) + func (d *MemoryDriver[Value]) Set(_ context.Context, key Key, value Value, ttl TTL) error + type MemoryOption func(*MemoryConfig) + func WithMemoryDefaultTTL(duration time.Duration) MemoryOption + type RedisClientConfig struct + Addr string + DB int + DialTimeout time.Duration + IdleTimeout time.Duration + MaxConnAge time.Duration + MaxRetries int + MinIdleConns int + Password string + PoolSize int + ReadTimeout time.Duration + UseTLS bool + Username string + WriteTimeout time.Duration + type RedisClientOption func(*RedisClientConfig) + func WithRedisAddr(addr string) RedisClientOption + func WithRedisDB(db int) RedisClientOption + func WithRedisMaxRetries(retries int) RedisClientOption + func WithRedisMinIdleConns(conns int) RedisClientOption + func WithRedisPassword(password string) RedisClientOption + func WithRedisPoolSize(size int) RedisClientOption + func WithRedisTLS(enable bool) RedisClientOption + func WithRedisTimeouts(dial, read, write, idle, maxConnAge time.Duration) RedisClientOption + func WithRedisUsername(username string) RedisClientOption + type RedisDriver struct + func NewRedisDriver[Value any](client *redis.Client, options ...RedisDriverOption) *RedisDriver[Value] + func (d *RedisDriver[Value]) Client() *redis.Client + func (d *RedisDriver[Value]) Close() error + func (d *RedisDriver[Value]) Delete(ctx context.Context, key Key) error + func (d *RedisDriver[Value]) Exists(ctx context.Context, keys ...Key) (int64, error) + func (d *RedisDriver[Value]) FlushDB(ctx context.Context) error + func (d *RedisDriver[Value]) Get(ctx context.Context, key Key) (Value, bool, error) + func (d *RedisDriver[Value]) Has(ctx context.Context, key Key) (bool, error) + func (d *RedisDriver[Value]) Keys(ctx context.Context, pattern string) ([]string, error) + func (d *RedisDriver[Value]) Ping(ctx context.Context) error + func (d *RedisDriver[Value]) Set(ctx context.Context, key Key, value Value, ttl TTL) error + func (d *RedisDriver[Value]) TTL(ctx context.Context, key Key) (time.Duration, error) + type RedisDriverConfig struct + DefaultTTL time.Duration + Prefix string + type RedisDriverOption func(*RedisDriverConfig) + func WithRedisDefaultTTL(duration time.Duration) RedisDriverOption + func WithRedisPrefix(prefix string) RedisDriverOption + type TTL struct + func WithTTL(d time.Duration) TTL + func WithTTLUntil(t time.Time) TTL