memory

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package memory provides an in-memory key-value storage backend.

This is the default storage backend, suitable for development and testing. Data is not persisted across restarts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store implements kvs.Store with in-memory maps.

func New

func New() *Store

New creates a new in-memory storage.

func (*Store) Close

func (s *Store) Close() error

Close releases storage resources.

func (*Store) Delete

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

Delete removes a key.

func (*Store) Get

func (s *Store) Get(ctx context.Context, key string) ([]byte, error)

Get retrieves a value by key.

func (*Store) Len

func (s *Store) Len() int

Len returns the number of entries (for testing).

func (*Store) List

func (s *Store) List(ctx context.Context, prefix string) ([]string, error)

List returns all keys matching the given prefix.

func (*Store) Set

func (s *Store) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error

Set stores a value with an optional TTL.

Jump to

Keyboard shortcuts

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