memory

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package memory provides an in-memory backend for omnistorage.

The memory backend is useful for:

  • Unit testing without filesystem access
  • Temporary storage and caching
  • Development and prototyping
  • Fast ephemeral storage

Data is stored in RAM and lost when the backend is closed or the process exits.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFromConfig

func NewFromConfig(_ map[string]string) (omnistorage.Backend, error)

NewFromConfig creates a new memory backend from a config map. The memory backend ignores all configuration options.

Types

type Backend

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

Backend implements omnistorage.ExtendedBackend for in-memory storage.

func New

func New() *Backend

New creates a new memory backend.

func (*Backend) Clear

func (b *Backend) Clear()

Clear removes all objects from the backend.

func (*Backend) Close

func (b *Backend) Close() error

Close releases any resources held by the backend.

func (*Backend) Copy

func (b *Backend) Copy(ctx context.Context, src, dst string) error

Copy copies an object from src to dst.

func (*Backend) Count

func (b *Backend) Count() int

Count returns the number of objects in the backend.

func (*Backend) Delete

func (b *Backend) Delete(ctx context.Context, p string) error

Delete removes a path.

func (*Backend) Exists

func (b *Backend) Exists(ctx context.Context, p string) (bool, error)

Exists checks if a path exists.

func (*Backend) Features

func (b *Backend) Features() omnistorage.Features

Features returns the capabilities of the memory backend.

func (*Backend) List

func (b *Backend) List(ctx context.Context, prefix string) ([]string, error)

List lists paths with the given prefix.

func (*Backend) Mkdir

func (b *Backend) Mkdir(ctx context.Context, p string) error

Mkdir creates a directory at the given path.

func (*Backend) Move

func (b *Backend) Move(ctx context.Context, src, dst string) error

Move moves/renames an object from src to dst.

func (*Backend) NewReader

func (b *Backend) NewReader(ctx context.Context, p string, opts ...omnistorage.ReaderOption) (io.ReadCloser, error)

NewReader creates a reader for the given path.

func (*Backend) NewWriter

func (b *Backend) NewWriter(ctx context.Context, p string, opts ...omnistorage.WriterOption) (io.WriteCloser, error)

NewWriter creates a writer for the given path.

func (*Backend) Rmdir

func (b *Backend) Rmdir(ctx context.Context, p string) error

Rmdir removes an empty directory.

func (*Backend) Size

func (b *Backend) Size() int64

Size returns the total size of all objects in the backend. This is useful for monitoring memory usage.

func (*Backend) Stat

Stat returns metadata about an object at the given path.

Jump to

Keyboard shortcuts

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