rueidiscache

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package rueidiscache provides a Redis cache backend for entcache using Rueidis.

It implements both the entcache.Cache and entcache.StampedeLocker interfaces, providing distributed caching capabilities with robust Cache Stampede Protection and high-performance RESP3 Client-Side Caching.

When multiple concurrent requests attempt to fetch the same missing key, exactly one request acquires a lock and queries the database. The other requests wait seamlessly using client-side caching until the data is populated, preventing database overload.

Invalidations for entcache multi-level caching are distributed through the "entcache:invalidations" Pub/Sub channel.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rueidis

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

Rueidis is a cache implementation that uses Rueidis.

func New

func New(c rueidis.Client) *Rueidis

New returns a new Rueidis cache level.

func (*Rueidis) Add

func (r *Rueidis) Add(ctx context.Context, k entcache.Key, e *entcache.Entry, ttl time.Duration) error

Add adds the entry to the cache and unblocks waiting callers.

func (*Rueidis) Close added in v0.5.0

func (r *Rueidis) Close() error

Close closes the cache.

func (*Rueidis) Del

func (r *Rueidis) Del(ctx context.Context, k entcache.Key) error

Del deletes an entry from the cache.

func (*Rueidis) Get

func (r *Rueidis) Get(ctx context.Context, k entcache.Key) (*entcache.Entry, error)

Get gets the entry from the cache.

func (*Rueidis) LockOrWait

func (r *Rueidis) LockOrWait(ctx context.Context, k entcache.Key) (bool, func(context.Context) (*entcache.Entry, error), func(context.Context), error)

LockOrWait implements StampedeLocker interface using RESP3 Client-Tracking.

func (*Rueidis) WatchInvalidations added in v0.5.0

func (r *Rueidis) WatchInvalidations(ctx context.Context, onInvalidate func(key entcache.Key)) error

WatchInvalidations watches for cache invalidation events and triggers the provided callback.

Jump to

Keyboard shortcuts

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