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: 10 Imported by: 0

Documentation

Overview

Package valkey provides atomic fenced leases backed by Valkey 9 or newer.

Index

Constants

View Source
const MaxPrefixBytes = 64

MaxPrefixBytes bounds the configured Valkey key prefix.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store persists atomic TTL leases and monotonic fencing counters in Valkey.

func New

func New(client valkeygo.Client, prefix string) (*Store, error)

New constructs a Valkey lease store without performing server checks.

func Open

func Open(ctx context.Context, client valkeygo.Client, prefix string) (*Store, error)

Open constructs a store and verifies the server version and eviction policy.

func (*Store) Acquire

func (store *Store) Acquire(
	ctx context.Context,
	key string,
	owner string,
	ttl time.Duration,
	_ time.Time,
) (lease.Lease, error)

Acquire creates or takes over an expired lease atomically.

func (*Store) Capabilities

func (*Store) Capabilities() lease.Capabilities

Capabilities reports the Valkey store's safety properties.

func (*Store) Check

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

Check verifies backend compatibility and safety configuration.

func (*Store) Heartbeat

func (store *Store) Heartbeat(
	ctx context.Context,
	owned lease.Lease,
	ttl time.Duration,
	_ time.Time,
) (lease.Lease, error)

Heartbeat extends a lease held by the current fenced owner.

func (*Store) Inspect

func (store *Store) Inspect(ctx context.Context, key string) (lease.Lease, error)

Inspect returns the active lease for a key.

func (*Store) Recover

func (store *Store) Recover(ctx context.Context, key string, fencingToken uint64) error

Recover deletes a lease only when its observed token still matches.

func (*Store) Release

func (store *Store) Release(ctx context.Context, owned lease.Lease) error

Release deletes a lease only when owner and token still match.

Jump to

Keyboard shortcuts

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