Help us shape the future of Go! Take the 2026 Go Developer Survey

rediscache

package
v0.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package rediscache is a Redis-backed cache that satisfies cache.Cache. Opt-in: importing this package pulls in github.com/redis/go-redis/v9; the root cache package has no driver dependency.

Uses SET key value PX millis for writes (atomic with TTL) and GET for reads. TTL is enforced by Redis itself, so there's no separate reaper to run — expired keys disappear automatically.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache is a Redis-backed implementation of cache.Cache. Pass any implementation of redis.UniversalClient — standalone, sentinel, or cluster — so consumers control connection / reconnect handling.

func New

func New(client redis.UniversalClient) *Cache

New builds a cache with no key prefix.

func WithPrefix

func WithPrefix(client redis.UniversalClient, prefix string) *Cache

WithPrefix prepends prefix + ":" to every key. Useful to keep multiple SDK consumers from colliding on a shared Redis instance.

func (*Cache) Delete

func (c *Cache) Delete(ctx context.Context, key string) error

Delete — see cache.Cache.Delete.

func (*Cache) GetBytes

func (c *Cache) GetBytes(ctx context.Context, key string) ([]byte, bool, error)

GetBytes — see cache.Cache.GetBytes.

func (*Cache) SetBytes

func (c *Cache) SetBytes(ctx context.Context, key string, value []byte, ttl time.Duration) error

SetBytes — see cache.Cache.SetBytes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL