storage

package
v0.0.0-...-53bd38a Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 4 Imported by: 1 module, 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(scheme string, f Factory)

Register makes a store factory available by scheme (e.g. "redis", "valkey"). Typically called from init() in the implementation module.

Types

type Factory

type Factory func(url string) (Store, error)

Factory creates a Store from a connection URL.

type Store

type Store interface {
	// Get returns the value for a simple key. Returns "" and nil if the key does not exist.
	Get(ctx context.Context, key string) (string, error)

	// Set stores a value with an expiration. Pass 0 for no expiration.
	Set(ctx context.Context, key, value string, ttl time.Duration) error

	// Incr atomically increments a simple key by delta and returns the new value.
	Incr(ctx context.Context, key string, delta int64) (int64, error)

	// HashIncr atomically increments a field in a hash by delta.
	HashIncr(ctx context.Context, key, field string, delta int64) (int64, error)

	// HashGet returns all fields of a hash as a string map.
	HashGet(ctx context.Context, key string) (map[string]string, error)

	// HashSetNX sets a field only if it does not already exist. Returns true if set.
	HashSetNX(ctx context.Context, key, field, value string) (bool, error)

	// Expire sets a TTL on a key. No-op if the key does not exist.
	Expire(ctx context.Context, key string, ttl time.Duration) error

	// Close releases the underlying connection.
	Close() error
}

Store provides key-value and hash operations for plugins that need persistent, cross-pod state (budget counters, session data, caches, rate limiting). Implementations with dependencies live in separate modules to isolate them, as redis does; filestore, a single process's store saved to one file, has none and lives in core.

func Open

func Open(scheme, url string) (Store, error)

Open creates a Store using the registered factory for the given scheme.

type StoreConsumer

type StoreConsumer interface {
	SetStore(Store)
}

StoreConsumer is implemented by plugins that keep state which must outlive the process. plugins.BuildWithDeps injects the process Store before Configure runs, as it injects spiffe.ProviderConsumer's and pricing.ResolverConsumer's.

A plugin must tolerate never being called: a process with no store to offer — any that is not a local install — passes nothing, and the plugin then keeps its state in memory as before.

Directories

Path Synopsis
Package filestore is a storage.Store kept in memory and saved to one file, for a single process that needs its plugins' state to outlive it: the laptop proxy, where a restart is routine and there is no redis.
Package filestore is a storage.Store kept in memory and saved to one file, for a single process that needs its plugins' state to outlive it: the laptop proxy, where a restart is routine and there is no redis.

Jump to

Keyboard shortcuts

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