cacheredis

package
v3.1.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package cacheredis provides a supported-adapter Redis cache store.

Use New with a redis.UniversalClient and Options to satisfy cache.Store for generated services or app-owned cache integrations. The adapter applies an optional key prefix, default TTL, miss handling, delete semantics, and defensive byte-slice copies.

HealthChecker checks Redis readiness without promoting cache keys to metrics or logs. Keep prefixes service-specific when a Redis deployment is shared.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HealthChecker

func HealthChecker(client redis.UniversalClient) ports.HealthChecker

HealthChecker returns a Redis cache dependency health checker.

Types

type Options

type Options struct {
	KeyPrefix  string
	DefaultTTL time.Duration
}

Options configures a Redis-backed cache store.

type Store

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

Store implements cache.Store using Redis.

func New

func New(client redis.UniversalClient, opts Options) *Store

New constructs a Redis-backed cache store.

func (*Store) Delete

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

Delete removes a cached value.

func (*Store) Get

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

Get returns a cached value if present.

func (*Store) HealthChecker

func (s *Store) HealthChecker() ports.HealthChecker

HealthChecker returns a Redis cache dependency health checker for this store.

func (*Store) Set

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

Set writes a cached value. When ttl is zero or negative, DefaultTTL is used.

Jump to

Keyboard shortcuts

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