providers

package
v0.0.0-...-c7901e9 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 1 Imported by: 0

README

providers

import "github.com/altessa-s/go-atlas/data/uniq/providers"

Package providers defines the Provider interface for unique value storage backends. Implementations live in subpackages and are injected into the top-level uniq.Uniq to supply the underlying key-value persistence.

Key types

Type / Interface Description
Provider Interface: Add, AddWithValue, Exist, GetValue, Remove, Clear

Subpackages

Package Description
nats NATS KV provider
noop No-op provider for testing
redis Redis-backed provider

Documentation

Overview

Package providers defines the Provider interface for unique value storage. Implementations are in subpackages: nats, redis, noop.

Example:

var store providers.Provider = redis.New(client)
store.Add(ctx, "unique-key")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider interface {
	// Add adds a key to the storage.
	// If the key already exists, it will be overwritten with the new TTL.
	Add(ctx context.Context, key string) error

	// AddWithValue adds a key with an associated value.
	AddWithValue(ctx context.Context, key string, value []byte) error

	// Exist checks if a key exists in the storage.
	// Returns true if the key exists and hasn't expired, false otherwise.
	Exist(ctx context.Context, key string) (bool, error)

	// GetValue retrieves the value associated with a key in the storage.
	GetValue(ctx context.Context, key string) ([]byte, error)

	// Remove removes a key from the storage.
	// If the key doesn't exist, no error is returned.
	Remove(ctx context.Context, key string) error

	// Clear removes all keys from the storage.
	// The operation should be atomic when possible.
	Clear(ctx context.Context) error
}

Provider defines the interface that must be implemented by any storage backend used with the uniq package. The interface provides methods for managing unique values with support for TTL (Time To Live).

Directories

Path Synopsis
Package nats provides NATS JetStream KeyValue storage for distributed unique values.
Package nats provides NATS JetStream KeyValue storage for distributed unique values.
Package noop provides no-operation provider for testing without external dependencies.
Package noop provides no-operation provider for testing without external dependencies.
Package redis provides Redis storage for distributed unique values with TTL and prefix support.
Package redis provides Redis storage for distributed unique values with TTL and prefix support.

Jump to

Keyboard shortcuts

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