valkey

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxPrefixBytes bounds the application prefix used in physical keys.
	MaxPrefixBytes = 64
	// MaxRetention is the longest terminal record TTL accepted by the adapter.
	MaxRetention = 365 * 24 * time.Hour
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Prefix isolates physical keys and must not contain braces.
	Prefix string
	// Retention keeps terminal records available before TTL deletion.
	Retention time.Duration
	// OwnerTokens returns a unique token for each ownership attempt.
	OwnerTokens func() (string, error)
}

Options configures physical key isolation, TTL, and token generation.

type Store

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

Store persists records through atomic single-key Valkey scripts.

func New

func New(client valkeygo.Client, options Options) (*Store, error)

New constructs a store without checking server version or eviction policy. Production startup should normally use Open.

func Open

func Open(ctx context.Context, client valkeygo.Client, options Options) (*Store, error)

Open constructs a store and rejects unsafe Valkey versions or eviction policy.

func (*Store) Acquire

Acquire atomically elects an owner or returns the retained semantic outcome.

func (*Store) Check

func (s *Store) Check(ctx context.Context) error

Check verifies the server version and correctness-critical eviction policy.

func (*Store) Complete

func (s *Store) Complete(ctx context.Context, request idempotency.CompleteRequest) (idempotency.Record, error)

Complete records a bounded successful result for a live current owner.

func (*Store) Expire

func (s *Store) Expire(ctx context.Context, key idempotency.Key) (idempotency.Record, error)

Expire records that an active lease elapsed according to Valkey server time.

func (*Store) Fail

Fail records a bounded terminal failure for a live current owner.

func (*Store) Heartbeat

func (s *Store) Heartbeat(ctx context.Context, request idempotency.HeartbeatRequest) (idempotency.Record, error)

Heartbeat extends a live owner's lease using Valkey server time.

func (*Store) Inspect

func (s *Store) Inspect(ctx context.Context, key idempotency.Key) (idempotency.Record, error)

Inspect returns the authoritative retained record for key.

func (*Store) Release

func (s *Store) Release(ctx context.Context, ownership idempotency.Ownership) (idempotency.Record, error)

Release abandons a live current owner's attempt.

Jump to

Keyboard shortcuts

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