idstore

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: Apache-2.0 Imports: 3 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 idstore implements the (principal, idempotency_key) → job_id dedupe map. Implementations may persist; the default is in-memory with a TTL sweep.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Principal string
	Key       string
	JobID     string
	CreatedAt time.Time
}

Entry is one stored mapping.

type Memory

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

Memory is an in-memory Store with a 24h default TTL.

func NewMemory

func NewMemory(ttl time.Duration) *Memory

NewMemory returns a Memory store with the given TTL. Zero ttl uses 24 hours.

func (*Memory) Get

func (s *Memory) Get(ctx context.Context, principal, key string) (Entry, bool, error)

Get returns the entry for (principal, key) if present.

func (*Memory) PutIfAbsent

func (s *Memory) PutIfAbsent(ctx context.Context, e Entry) (Entry, bool, error)

PutIfAbsent inserts e if no entry exists for (principal, key).

func (*Memory) Sweep

func (s *Memory) Sweep(ctx context.Context, olderThan time.Time) (int, error)

Sweep removes entries older than the cutoff.

type Store

type Store interface {
	PutIfAbsent(ctx context.Context, e Entry) (Entry, bool, error)
	Get(ctx context.Context, principal, key string) (Entry, bool, error)
	Sweep(ctx context.Context, olderThan time.Time) (int, error)
}

Store is the dedupe interface. PutIfAbsent inserts entry and returns the stored entry plus true if the row is new; if a row already exists, it returns the existing entry and false.

Jump to

Keyboard shortcuts

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