kv

package
v0.0.0-...-96862d9 Latest Latest
Warning

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

Go to latest
Published: May 16, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCompressionError

func IsCompressionError(e error) bool

func IsKeyNotFoundError

func IsKeyNotFoundError(e error) bool

func IsNotImplementedError

func IsNotImplementedError(e error) bool

Types

type CompressionError

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

func NewCompressionError

func NewCompressionError(data []byte, err error) CompressionError

func (CompressionError) Error

func (e CompressionError) Error() string

type ErrType

type ErrType string
const (
	KeyNotFound    ErrType = "KEY_NOT_FOUND_ERROR"
	Compression    ErrType = "COMPRESSION_ERROR"
	NotImplemented ErrType = "NOT_IMPLEMENTED_ERROR"
	Unknown        ErrType = "UNKNOWN_ERROR"
)

type InMemory

type InMemory struct {
	sync.Mutex
	Db map[string]*Value
}

InMemory is an in-memory data structure implementation of the KV interface

func (*InMemory) Delete

func (im *InMemory) Delete(key string) error

Delete will remove a key from the KV Db

func (*InMemory) Get

func (im *InMemory) Get(key string) (*Value, error)

Get retrieves the value of the given key

func (*InMemory) Put

func (im *InMemory) Put(key string, value *Value) error

Put inserts a new key/Value pair in the KV Db It wont raise any error as the operation is safe

type KV

type KV interface {
	Put(k string, v *Value) error
	Get(k string) (*Value, error)
	Delete(k string) error
}

func NewKV

func NewKV(kind Kind) (KV, error)

type KeyNotFoundError

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

func NewKeyNotFoundError

func NewKeyNotFoundError(key string) KeyNotFoundError

func (KeyNotFoundError) Error

func (e KeyNotFoundError) Error() string

type Kind

type Kind string
const (
	INMEMORY Kind = "in-memory"
)

func KVFromName

func KVFromName(name string) (Kind, error)

type NotImplementedError

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

func NewNotImplementedError

func NewNotImplementedError(impl string) NotImplementedError

func (NotImplementedError) Error

func (e NotImplementedError) Error() string

type Value

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

func NewValue

func NewValue(data []byte) (*Value, error)

func (*Value) Data

func (v *Value) Data() string

func (*Value) LastModified

func (v *Value) LastModified() time.Time

func (*Value) MD5

func (v *Value) MD5() string

func (*Value) Text

func (v *Value) Text() string

Jump to

Keyboard shortcuts

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