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

redis

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidClient is returned when Client is nil.
	ErrInvalidClient = errors.New("redis: Client must not be nil")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// Client is the Rueidis client (REQUIRED, must not be nil).
	Client rueidis.Client

	// KeyPrefix is the prefix for all keys (OPTIONAL).
	// Default: empty (no prefix)
	KeyPrefix string

	// ClientSideCaching enables client-side caching (OPTIONAL).
	// Default: false
	ClientSideCaching bool
}

Config holds configuration for RedisStore.

type RedisStore

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

RedisStore is a Redis-backed cache store using Rueidis client. Thread-safe for concurrent use.

Reference: .references/seaguest-cache/redis_cache.go (Redis operations) Reference: .references/gookit-cache/goredis/goredis.go (Redis client wrapper)

func New

func New(cfg Config) (*RedisStore, error)

New creates a new RedisStore with the given configuration. Returns an error if the configuration is invalid.

func NewWithClient deprecated

func NewWithClient(client rueidis.Client) *RedisStore

NewWithClient creates a new RedisStore with the given Rueidis client.

Deprecated: Use New with Config instead.

func NewWithPrefix deprecated

func NewWithPrefix(client rueidis.Client, prefix string) *RedisStore

NewWithPrefix creates a new RedisStore with a key prefix.

Deprecated: Use New with Config instead.

func (*RedisStore) Clear

func (s *RedisStore) Clear(ctx context.Context) error

Clear removes all entries from Redis. If a prefix is set, only keys with that prefix are removed. Otherwise, FLUSHDB is used to clear the entire database.

Reference: .references/gookit-cache/goredis/goredis.go:87 (Clear method)

func (*RedisStore) Close

func (s *RedisStore) Close() error

Close releases resources associated with the Redis client. Idempotent - safe to call multiple times.

func (*RedisStore) Delete

func (s *RedisStore) Delete(ctx context.Context, key string) error

Delete removes a value from Redis. Idempotent - deleting a non-existent key returns nil.

Reference: .references/seaguest-cache/redis_cache.go:82 (delete method)

func (*RedisStore) Get

func (s *RedisStore) Get(ctx context.Context, key string) ([]byte, error)

Get retrieves a value from Redis by key. Returns cache.ErrNotFound if the key doesn't exist.

Reference: .references/seaguest-cache/redis_cache.go:29 (get method)

func (*RedisStore) Set

func (s *RedisStore) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error

Set stores a value in Redis with the specified TTL.

TTL semantics: - ttl == 0: no expiration - ttl < 0: no expiration - ttl > 0: expires after the specified duration

Reference: .references/seaguest-cache/redis_cache.go:60 (set method)

Jump to

Keyboard shortcuts

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