keyvaluestore

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileKeyValueStore

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

FileKeyValueStore stores each value into a separate file. KeySerializer maps a key to a unique file path (raletive to the store path) ValueSerializer and ValueDeserializer serializes/de-serializes a value to and from a byte array that is stored in the path derived from the key.

func New

New creates a new instance of FileKeyValueStore using provided options

func (*FileKeyValueStore) Delete

func (fkvs *FileKeyValueStore) Delete(key interface{}) error

Delete deletes the value for a key.

func (*FileKeyValueStore) GetPath

func (fkvs *FileKeyValueStore) GetPath() string

GetPath returns the store path

func (*FileKeyValueStore) Load

func (fkvs *FileKeyValueStore) Load(key interface{}) (interface{}, error)

Load returns the value stored in the store for a key. If a value for the key was not found, returns (nil, ErrNotFound)

func (*FileKeyValueStore) Store

func (fkvs *FileKeyValueStore) Store(key interface{}, value interface{}) error

Store sets the value for the key.

type FileKeyValueStoreOptions

type FileKeyValueStoreOptions struct {
	// Store path, mandatory
	Path string
	// Optional. If not provided, default key serializer is used.
	KeySerializer KeySerializer
	// Optional. If not provided, default Marshaller is used.
	Marshaller Marshaller
	// Optional. If not provided, default Unmarshaller is used.
	Unmarshaller Unmarshaller
}

FileKeyValueStoreOptions allow overriding store defaults

type KeySerializer

type KeySerializer func(key interface{}) (string, error)

KeySerializer converts a key to a unique fila path

type Marshaller

type Marshaller func(value interface{}) ([]byte, error)

Marshaller marshals a value into a byte array

type Unmarshaller

type Unmarshaller func(value []byte) (interface{}, error)

Unmarshaller unmarshals a value from a byte array

Jump to

Keyboard shortcuts

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