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 ¶
- func NewFromConfig(_ map[string]string) (omnistorage.Backend, error)
- type Backend
- func (b *Backend) Clear()
- func (b *Backend) Close() error
- func (b *Backend) Copy(ctx context.Context, src, dst string) error
- func (b *Backend) Count() int
- func (b *Backend) Delete(ctx context.Context, p string) error
- func (b *Backend) Exists(ctx context.Context, p string) (bool, error)
- func (b *Backend) Features() omnistorage.Features
- func (b *Backend) List(ctx context.Context, prefix string) ([]string, error)
- func (b *Backend) Mkdir(ctx context.Context, p string) error
- func (b *Backend) Move(ctx context.Context, src, dst string) error
- func (b *Backend) NewReader(ctx context.Context, p string, opts ...omnistorage.ReaderOption) (io.ReadCloser, error)
- func (b *Backend) NewWriter(ctx context.Context, p string, opts ...omnistorage.WriterOption) (io.WriteCloser, error)
- func (b *Backend) Rmdir(ctx context.Context, p string) error
- func (b *Backend) Size() int64
- func (b *Backend) Stat(ctx context.Context, p string) (omnistorage.ObjectInfo, error)
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 (*Backend) Features ¶
func (b *Backend) Features() omnistorage.Features
Features returns the capabilities of the memory backend.
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) Size ¶
Size returns the total size of all objects in the backend. This is useful for monitoring memory usage.
func (*Backend) Stat ¶
func (b *Backend) Stat(ctx context.Context, p string) (omnistorage.ObjectInfo, error)
Stat returns metadata about an object at the given path.