memory

package
v0.50.3 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package memory supplies an explicit single-process lockout authority. It is useful for tests and local applications; it is never a Redis failure fallback.

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 is a mutex-protected, bounded process-local lockout authority.

func New

func New(maxEntries int, source clock.Clock) (*Backend, error)

New creates a bounded in-memory authority using source as its clock.

func (*Backend) Close

func (b *Backend) Close() error

Close seals the backend and clears its retained lockout entries under its mutex.

func (*Backend) LockoutBegin

func (b *Backend) LockoutBegin(ctx context.Context, key lockout.Key, policy lockout.Policy, candidate lockout.Generation) (lockout.Admission, error)

LockoutBegin atomically checks the lock and returns the current snapshot for an allowed attempt.

func (*Backend) LockoutFinish

func (b *Backend) LockoutFinish(ctx context.Context, key lockout.Key, policy lockout.Policy, snapshot lockout.Snapshot, outcome lockout.Outcome) (lockout.Decision, error)

LockoutFinish atomically applies an admitted outcome; stale successes cannot clear newer failures, and expired generations do not mutate current state.

func (*Backend) LockoutReset

func (b *Backend) LockoutReset(ctx context.Context, key lockout.Key, policy lockout.Policy) (bool, error)

LockoutReset atomically removes the key's state and reports whether it existed.

Jump to

Keyboard shortcuts

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