memory

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package memory provides an in-memory storage implementation for idempotency records.

This storage is suitable for development, testing, and single-instance applications. For production distributed systems, use Redis or PostgreSQL storage instead.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Storage

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

Storage is an in-memory implementation of idempotency.Storage

func NewMemoryStorage

func NewMemoryStorage() *Storage

NewMemoryStorage creates a new in-memory storage instance

func (*Storage) Close

func (s *Storage) Close() error

Close closes the storage (no-op for memory storage)

func (*Storage) Delete

func (s *Storage) Delete(ctx context.Context, key string) error

Delete removes an idempotency record

func (*Storage) Exists

func (s *Storage) Exists(ctx context.Context, key string) (bool, error)

Exists checks if a record exists

func (*Storage) Get

func (s *Storage) Get(ctx context.Context, key string) (*idempotency.Record, error)

Get retrieves an idempotency record by key

func (*Storage) Set

func (s *Storage) Set(ctx context.Context, record *idempotency.Record, ttl time.Duration) error

Set stores an idempotency record

func (*Storage) TryLock

func (s *Storage) TryLock(ctx context.Context, key string, ttl time.Duration) (bool, error)

TryLock attempts to acquire a lock for the given key

func (*Storage) Unlock

func (s *Storage) Unlock(ctx context.Context, key string) error

Unlock releases a lock for the given key

Jump to

Keyboard shortcuts

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