storage

package
v1.0.55 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: GPL-3.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrZeroKey is returned if an attempt was made to inset a 0-length key.
	ErrZeroKey = errors.New("0-length key")

	// ErrNotFound is returned if an unknown key is attempted to be retrieved.
	ErrNotFound = errors.New("not found")
)

Functions

This section is empty.

Types

type AESEncryptedStorage

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

AESEncryptedStorage is a storage type which is backed by a json-file. The json-file contains key-value mappings, where the keys are _not_ encrypted, only the values are.

func NewAESEncryptedStorage

func NewAESEncryptedStorage(filename string, key []byte) *AESEncryptedStorage

NewAESEncryptedStorage creates a new encrypted storage backed by the given file/key

func (*AESEncryptedStorage) Del

func (s *AESEncryptedStorage) Del(key string)

Del removes a key-value pair. If the key doesn't exist, the method is a noop.

func (*AESEncryptedStorage) Get

func (s *AESEncryptedStorage) Get(key string) (string, error)

Get returns the previously stored value, or an error if it does not exist or key is of 0-length.

func (*AESEncryptedStorage) Put

func (s *AESEncryptedStorage) Put(key, value string)

Put stores a value by key. 0-length keys results in noop.

type EphemeralStorage

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

EphemeralStorage is an in-memory storage that does not persist values to disk. Mainly used for testing

func (*EphemeralStorage) Del

func (s *EphemeralStorage) Del(key string)

Del removes a key-value pair. If the key doesn't exist, the method is a noop.

func (*EphemeralStorage) Get

func (s *EphemeralStorage) Get(key string) (string, error)

Get returns the previously stored value, or an error if the key is 0-length or unknown.

func (*EphemeralStorage) Put

func (s *EphemeralStorage) Put(key, value string)

Put stores a value by key. 0-length keys results in noop.

type NoStorage

type NoStorage struct{}

NoStorage is a dummy construct which doesn't remember anything you tell it

func (*NoStorage) Del

func (s *NoStorage) Del(key string)

func (*NoStorage) Get

func (s *NoStorage) Get(key string) (string, error)

func (*NoStorage) Put

func (s *NoStorage) Put(key, value string)

type Storage

type Storage interface {
	// Put stores a value by key. 0-length keys results in noop.
	Put(key, value string)

	// Get returns the previously stored value, or an error if the key is 0-length
	// or unknown.
	Get(key string) (string, error)

	// Del removes a key-value pair. If the key doesn't exist, the method is a noop.
	Del(key string)
}

func NewEphemeralStorage

func NewEphemeralStorage() Storage

Jump to

Keyboard shortcuts

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