cache

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCacheNotConnected = errors.New("cache not connected")
	ErrCacheQueryFailed  = errors.New("cache query failed")

	StatusCacheNotConnected = status.New(codes.Aborted, "cache not connected")
	StatusCacheQueryFailed  = status.New(codes.Internal, "cache query failed")
)

Functions

func Close

func Close() error

func DeleteAfterScanExecuteInt

func DeleteAfterScanExecuteInt(ctx context.Context, pattern string, f func(key string, value int) error) error

ScanExecuteInt iterates through keys in the cache matching a given pattern and executes a function for each key whose value can be parsed as an integer. It only considers keys of type 'string'. If the pattern is an empty string, it defaults to "*" to scan all keys.

func Incr

func Incr(ctx context.Context, key string) (int64, error)

func InitConnection

func InitConnection(opts ...initConnOpt) error

func Keys

func Keys(ctx context.Context, pattern string) ([]string, error)

func ScanExecute

func ScanExecute[T any](ctx context.Context, pattern string, f func(key string, value T) error) error

ScanExecute iterates through keys in the cache matching a given pattern and executes a function for each key that can be successfully deserialized into the generic type T. It supports keys stored as JSON strings or Hashes. If the pattern is an empty string, it defaults to "*" to scan all keys.

func ToStatus

func ToStatus(err error) *status.Status

func WithAddr

func WithAddr(addr string) initConnOpt

func WithDb

func WithDb(db int) initConnOpt

func WithPassword

func WithPassword(password string) initConnOpt

func WithUsername

func WithUsername(username string) initConnOpt

Types

This section is empty.

Jump to

Keyboard shortcuts

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