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

Overview

Package valkey provides native atomic fenced leases for Valkey.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Guard

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

Guard is an opaque active-ownership proof for atomic Valkey protected writes.

func (Guard) Owner

func (guard Guard) Owner() string

Owner returns the lease owner compared by a protected write.

func (Guard) StorageKey

func (guard Guard) StorageKey() string

StorageKey returns the redacted Valkey lease hash key.

func (Guard) Token

func (guard Guard) Token() string

Token returns the exact decimal fencing token compared by a protected write.

type Store

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

Store persists atomic leases using backend-time Lua operations.

func New

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

New constructs a native Valkey backend. The client owns reconnect, ACL, TLS, routing, and timeout policy and must be closed by its creator.

func Open

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

Open constructs a backend and verifies Valkey 9 plus noeviction policy.

func (*Store) Guard

func (store *Store) Guard(owned lease.Record) (Guard, error)

Guard derives the backend coordinates required to validate owned atomically. The protected writer must use the same Valkey deployment as this Store.

func (*Store) Release

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

Release atomically deletes only a matching lease; missing is idempotent.

func (*Store) Renew

func (store *Store) Renew(
	ctx context.Context,
	owned lease.Record,
	ttl time.Duration,
) (lease.Record, error)

Renew atomically compares owner and token before extending backend expiry.

func (*Store) TryAcquire

func (store *Store) TryAcquire(
	ctx context.Context,
	key lease.Key,
	owner string,
	ttl time.Duration,
) (lease.Record, error)

TryAcquire atomically increments the persistent counter and creates a lease.

func (*Store) Validate

func (store *Store) Validate(ctx context.Context, owned lease.Record) (lease.Record, error)

Validate atomically compares owner and token against an unexpired lease.

Jump to

Keyboard shortcuts

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