cache

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRedisCache

func NewRedisCache(addr string, password string, db int, logger *logrus.Logger) (ports.Cache, error)

Types

type RedisCache

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

func (*RedisCache) Close

func (r *RedisCache) Close() error

func (*RedisCache) Delete

func (r *RedisCache) Delete(ctx context.Context, key string) error

func (*RedisCache) Get

func (r *RedisCache) Get(ctx context.Context, key string) (string, error)

func (*RedisCache) InvalidateByPrefix added in v1.2.0

func (r *RedisCache) InvalidateByPrefix(ctx context.Context, prefix string) error

InvalidateByPrefix deletes all keys that start with the given prefix. It uses the SCAN command to iterate over keys matching the pattern and then deletes them. Note: While SCAN is generally safe for production, performing many DEL commands in a tight loop could still put load on Redis. For extremely large datasets, consider optimizing further (e.g., pipelining DEL commands, or relying on TTL for less critical keys).

func (*RedisCache) Set

func (r *RedisCache) Set(ctx context.Context, key string, value []byte, expiration time.Duration) error

Jump to

Keyboard shortcuts

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