ops

package
v0.6.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConsumeIfExists

func ConsumeIfExists(ctx context.Context, client goredis.UniversalClient, key string) (bool, error)

ConsumeIfExists atomically checks and deletes a single key.

func DeleteByPattern

func DeleteByPattern(ctx context.Context, client goredis.UniversalClient, pattern string, opts DeleteByPatternOptions) (int, error)

DeleteByPattern scans and deletes keys in batches. When DryRun is enabled, it only counts matches and does not delete them.

func JitterTTL

func JitterTTL(ttl time.Duration, ratio float64) time.Duration

JitterTTL adds symmetric jitter around the input TTL using the provided ratio.

func ScanKeys

func ScanKeys(ctx context.Context, client goredis.UniversalClient, pattern string, count int64) ([]string, error)

ScanKeys collects keys using SCAN for the provided pattern.

Types

type DeleteBatch

type DeleteBatch struct {
	Pattern string
	Keys    []string
	Matched int
	Deleted int
	DryRun  bool
}

DeleteBatch contains a single scan/delete batch result.

type DeleteByPatternOptions

type DeleteByPatternOptions struct {
	ScanCount     int64
	BatchSize     int
	UseUnlink     bool
	DeleteTimeout time.Duration
	DryRun        bool
	OnBatch       func(DeleteBatch)
}

DeleteByPatternOptions controls batched key deletion.

func DefaultDeleteByPatternOptions

func DefaultDeleteByPatternOptions() DeleteByPatternOptions

DefaultDeleteByPatternOptions returns the canonical pattern-deletion defaults.

Jump to

Keyboard shortcuts

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