redis

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package redis provides a Redis-backed gateway.Coordinator, for sharing certificate issuance arbitration and distribution across every process in a deployment. It is a separate package specifically so that importing the root gateway package never pulls in github.com/redis/go-redis/v9 for applications that do not want it (e.g. those using the default gateway.MemoryCoordinator, or a different Coordinator entirely).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Coordinator

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

Coordinator is a gateway.Coordinator backed by a Redis client: Put/Get use plain SET/GET with the given TTL, and TryLock uses SET NX PX for acquisition and the Lua script above for release - a real mutual exclusion primitive, unlike a best-effort distributed lock.

func New

func New(client goredis.Cmdable, opts ...Option) *Coordinator

New creates a Coordinator backed by client. client may be a *redis.Client, *redis.ClusterClient, or any other goredis.Cmdable implementation.

func (*Coordinator) Get

func (c *Coordinator) Get(ctx context.Context, key string) ([]byte, bool, error)

Get implements gateway.Coordinator.

func (*Coordinator) Put

func (c *Coordinator) Put(ctx context.Context, key string, value []byte, ttl time.Duration) error

Put implements gateway.Coordinator.

func (*Coordinator) TryLock

func (c *Coordinator) TryLock(ctx context.Context, key string, ttl time.Duration) (func(context.Context) error, error)

TryLock implements gateway.Coordinator.

type Option

type Option func(*Coordinator)

Option configures a Coordinator created with New.

func WithKeyPrefix

func WithKeyPrefix(prefix string) Option

WithKeyPrefix namespaces every key this Coordinator reads or writes, so multiple gateway deployments (or unrelated applications) can share one Redis instance/database without colliding. Defaults to no prefix.

Jump to

Keyboard shortcuts

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