Help us shape the future of Go! Take the 2026 Go Developer Survey

memory

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package memory implements explicit single-process leases. It never evicts live owners to make space and is never an automatic fallback for Redis failures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

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

Backend owns a bounded set of leases using Go's monotonic clock. No background goroutine is needed: an operation checks only its own key, and a new key reclaims expired owners in deadline order before checking capacity.

func New

func New(maxEntries int) (*Backend, error)

New constructs a local lease backend with a positive entry bound.

func (*Backend) Close

func (b *Backend) Close() error

Close invalidates this explicit local authority. Close managers first so their callbacks and cleanup finish while the backend is still available.

func (*Backend) FoundryAdapter

func (*Backend) FoundryAdapter(frameworkadapter.Seal)

FoundryAdapter marks the backend as framework-owned adapter I/O.

func (*Backend) LeaseAcquire

func (b *Backend) LeaseAcquire(ctx context.Context, key lease.Key, owner lease.Owner, ttl time.Duration) (bool, error)

LeaseAcquire acquires an absent or expired key; capacity exhaustion returns fault.Conflict.

func (*Backend) LeaseForceRelease

func (b *Backend) LeaseForceRelease(ctx context.Context, key lease.Key) (bool, error)

LeaseForceRelease administratively removes key regardless of its owner.

func (*Backend) LeaseRelease

func (b *Backend) LeaseRelease(ctx context.Context, key lease.Key, owner lease.Owner) (bool, error)

LeaseRelease removes key only if owner matches its unexpired owner.

func (*Backend) LeaseRenew

func (b *Backend) LeaseRenew(ctx context.Context, key lease.Key, owner lease.Owner, ttl time.Duration) (bool, error)

LeaseRenew extends the expiry only if owner matches its unexpired owner.

func (*Backend) LeaseTransfer

func (b *Backend) LeaseTransfer(ctx context.Context, key lease.Key, from, to lease.Owner, ttl time.Duration) (bool, error)

LeaseTransfer replaces from with to and renews, only while from owns key.

Jump to

Keyboard shortcuts

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