redis

package
v0.0.0-...-69b46a9 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectURL

func ConnectURL(url string) (*goredis.Client, error)

ConnectURL parses url, creates a client, and verifies connectivity with PING.

func NormalizeKeyPrefix

func NormalizeKeyPrefix(prefix string) string

NormalizeKeyPrefix ensures a non-empty prefix ends with ":".

Types

type CacheStore

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

CacheStore implements cache.Cache using Redis.

func New

func New(cfg Config) (*CacheStore, error)

New creates a CacheStore and verifies the Redis connection with PING.

func (*CacheStore) CompareAndSubtract

func (s *CacheStore) CompareAndSubtract(key string, expected int64) (int64, error)

CompareAndSubtract subtracts expected from the counter when current >= expected. When current < expected, leaves the value unchanged and returns current.

func (*CacheStore) Delete

func (s *CacheStore) Delete(key string) error

Delete removes the entry for key. A missing key is not an error.

func (*CacheStore) DeleteByPrefix

func (s *CacheStore) DeleteByPrefix(ctx context.Context, prefix string) error

DeleteByPrefix removes all entries whose key starts with prefix.

func (*CacheStore) DeleteExpired

func (s *CacheStore) DeleteExpired(ctx context.Context) (int64, error)

DeleteExpired is a no-op for Redis; TTL keys are evicted by the server.

func (*CacheStore) Get

func (s *CacheStore) Get(key string, dest any) (bool, error)

Get retrieves the cached value for key and unmarshals it into dest.

func (*CacheStore) Incr

func (s *CacheStore) Incr(key string, delta int64, ttl time.Duration) (int64, error)

Incr atomically increments a JSON-number counter and refreshes TTL.

func (*CacheStore) Set

func (s *CacheStore) Set(key string, value any, ttl time.Duration) error

Set stores value under key with the given TTL.

type Config

type Config struct {
	URL       string
	KeyPrefix string
}

Config holds Redis cache connection settings.

type JobQueue

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

JobQueue implements jobs.Queue using Redis lists and a delayed sorted set.

func NewJobQueue

func NewJobQueue(cfg QueueConfig) (*JobQueue, error)

NewJobQueue creates a JobQueue and verifies the Redis connection with PING.

func (*JobQueue) Complete

func (q *JobQueue) Complete(ctx context.Context, id string) error

Complete marks a job as done.

func (*JobQueue) Dequeue

func (q *JobQueue) Dequeue(ctx context.Context) (*jobs.Job, error)

Dequeue atomically claims the next pending job.

func (*JobQueue) Enqueue

func (q *JobQueue) Enqueue(ctx context.Context, job jobs.Job) error

Enqueue inserts a new job into the queue.

func (*JobQueue) Fail

func (q *JobQueue) Fail(ctx context.Context, id string, jobErr error) error

Fail re-queues a job for retry or marks it as permanently failed.

type QueueConfig

type QueueConfig struct {
	URL       string
	KeyPrefix string
}

QueueConfig holds Redis job queue connection settings.

Jump to

Keyboard shortcuts

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