mem

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFactory

func NewFactory() location.Factory

NewFactory creates a persistent mem backend

Types

type MemoryBackend

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

MemoryBackend is a mock backend that uses a map for storing all data in memory. This should only be used for tests.

func New

func New() *MemoryBackend

New returns a new backend that saves all data in a map in memory.

func (*MemoryBackend) Close

func (be *MemoryBackend) Close() error

Close closes the backend.

func (*MemoryBackend) Connections

func (be *MemoryBackend) Connections() uint

func (*MemoryBackend) Delete

func (be *MemoryBackend) Delete(ctx context.Context) error

Delete removes all data in the backend.

func (*MemoryBackend) HasAtomicReplace

func (be *MemoryBackend) HasAtomicReplace() bool

HasAtomicReplace returns whether Save() can atomically replace files

func (*MemoryBackend) Hasher

func (be *MemoryBackend) Hasher() hash.Hash

Hasher may return a hash function for calculating a content hash for the backend

func (*MemoryBackend) IsNotExist

func (be *MemoryBackend) IsNotExist(err error) bool

IsNotExist returns true if the file does not exist.

func (*MemoryBackend) List

List returns a channel which yields entries from the backend.

func (*MemoryBackend) Load

func (be *MemoryBackend) Load(ctx context.Context, h backend.Handle, length int, offset int64, fn func(rd io.Reader) error) error

Load runs fn with a reader that yields the contents of the file at h at the given offset.

func (*MemoryBackend) Location

func (be *MemoryBackend) Location() string

Location returns the location of the backend (RAM).

func (*MemoryBackend) Remove

func (be *MemoryBackend) Remove(ctx context.Context, h backend.Handle) error

Remove deletes a file from the backend.

func (*MemoryBackend) Save

Save adds new Data to the backend.

func (*MemoryBackend) Stat

Stat returns information about a file in the backend.

Jump to

Keyboard shortcuts

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