storer

package
v0.0.0-...-80327fb Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package storer implements an abstract key-value storage interface.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStorerExist    = errors.New("storer: value already exists")
	ErrStorerNotExist = errors.New("storer: value does not exist")
)

Errors which may be returned by a Storer.

Functions

This section is empty.

Types

type Storer

type Storer interface {
	// Load a value. Returns the value and its length. If the value does not
	// exist, Load returns ErrStorerNotExist
	Load(key []byte) (value io.ReadCloser, length uint64, err error)

	// Store a value. If value is nil, Store only checks if the value could
	// be stored. If the value is already stored, Store returns
	// ErrStorerExist.
	Store(key []byte, length uint64, value io.Reader) error

	// Delete a value. If the value does not exist, Delete returns
	// ErrStorerNotExist.
	Delete(key []byte) error

	// Close the Storer.
	Close() error
}

Storer stores key-value pairs. Storer is safe for concurrent use. Keys must be at least one byte in length.

func NewFileStorer

func NewFileStorer(dir string, maxLength, maxCount uint64) (Storer, error)

NewFileStorer returns a Storer backed by the filesystem. Individual files may be at most maxLength bytes and the Storer may contain at most maxCount files.

Jump to

Keyboard shortcuts

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