memkv

package
v0.10.3-0...-54aaeda Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 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 ByteSliceValue

type ByteSliceValue []byte

func (ByteSliceValue) ByteSlice

func (v ByteSliceValue) ByteSlice() []byte

func (ByteSliceValue) String

func (v ByteSliceValue) String() string

type MemoryKV

type MemoryKV struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

MemoryKV implements BaseKv interface and relies on underling btree.BTree. As its name implies, all data is stored in memory.

func NewMemoryKV

func NewMemoryKV() *MemoryKV

NewMemoryKV returns an in-memory kvBase for testing.

func (*MemoryKV) Close

func (kv *MemoryKV) Close()

Close dummy close

func (*MemoryKV) Get

func (kv *MemoryKV) Get(key string) string

Get return value if key exists, or return empty string

func (*MemoryKV) Has

func (kv *MemoryKV) Has(key string) (bool, error)

func (*MemoryKV) HasPrefix

func (kv *MemoryKV) HasPrefix(prefix string) (bool, error)

func (*MemoryKV) Load

func (kv *MemoryKV) Load(key string) (string, error)

Load loads an object with @key.

func (*MemoryKV) LoadBytes

func (kv *MemoryKV) LoadBytes(key string) ([]byte, error)

LoadBytes loads an object with @key.

func (*MemoryKV) LoadBytesRange

func (kv *MemoryKV) LoadBytesRange(key, endKey string, limit int) ([]string, [][]byte, error)

LoadBytesRange loads objects with range @startKey to @endKey with @limit number of objects.

func (*MemoryKV) LoadBytesWithDefault

func (kv *MemoryKV) LoadBytesWithDefault(key string, defaultValue []byte) []byte

LoadBytesWithDefault loads an object with @key. If the object does not exist, @defaultValue will be returned.

func (*MemoryKV) LoadBytesWithPrefix

func (kv *MemoryKV) LoadBytesWithPrefix(key string) ([]string, [][]byte, error)

LoadBytesWithPrefix returns all keys & values with given prefix.

func (*MemoryKV) LoadWithPrefix

func (kv *MemoryKV) LoadWithPrefix(key string) ([]string, []string, error)

LoadWithPrefix returns all keys & values with given prefix.

func (*MemoryKV) MultiLoad

func (kv *MemoryKV) MultiLoad(keys []string) ([]string, error)

MultiLoad loads objects with multi @keys.

func (*MemoryKV) MultiLoadBytes

func (kv *MemoryKV) MultiLoadBytes(keys []string) ([][]byte, error)

MultiLoadBytes loads objects with multi @keys.

func (*MemoryKV) MultiRemove

func (kv *MemoryKV) MultiRemove(keys []string) error

MultiRemove removes given @keys in MemoryKV atomicly.

func (*MemoryKV) MultiSave

func (kv *MemoryKV) MultiSave(kvs map[string]string) error

MultiSave saves given key-value pairs in MemoryKV atomicly.

func (*MemoryKV) MultiSaveAndRemove

func (kv *MemoryKV) MultiSaveAndRemove(saves map[string]string, removals []string, preds ...predicates.Predicate) error

MultiSaveAndRemove saves and removes given key-value pairs in MemoryKV atomicly.

func (*MemoryKV) MultiSaveAndRemoveWithPrefix

func (kv *MemoryKV) MultiSaveAndRemoveWithPrefix(saves map[string]string, removals []string, preds ...predicates.Predicate) error

MultiSaveAndRemoveWithPrefix saves key-value pairs in @saves, & remove key with prefix in @removals in MemoryKV atomically.

func (*MemoryKV) MultiSaveBytes

func (kv *MemoryKV) MultiSaveBytes(kvs map[string][]byte) error

MultiSaveBytes saves given key-value pairs in MemoryKV atomicly.

func (*MemoryKV) MultiSaveBytesAndRemove

func (kv *MemoryKV) MultiSaveBytesAndRemove(saves map[string][]byte, removals []string) error

MultiSaveBytesAndRemove saves and removes given key-value pairs in MemoryKV atomicly.

func (*MemoryKV) MultiSaveBytesAndRemoveWithPrefix

func (kv *MemoryKV) MultiSaveBytesAndRemoveWithPrefix(saves map[string][]byte, removals []string) error

MultiSaveBytesAndRemoveWithPrefix saves key-value pairs in @saves, & remove key with prefix in @removals in MemoryKV atomically.

func (*MemoryKV) Remove

func (kv *MemoryKV) Remove(key string) error

Remove deletes an object with @key.

func (*MemoryKV) RemoveWithPrefix

func (kv *MemoryKV) RemoveWithPrefix(key string) error

RemoveWithPrefix remove key of given prefix in MemoryKV atomicly.

func (*MemoryKV) Save

func (kv *MemoryKV) Save(key, value string) error

Save object with @key to btree. Object value is @value.

func (*MemoryKV) SaveBytes

func (kv *MemoryKV) SaveBytes(key string, value []byte) error

SaveBytes object with @key to btree. Object value is @value.

type StringValue

type StringValue string

func (StringValue) ByteSlice

func (v StringValue) ByteSlice() []byte

func (StringValue) String

func (v StringValue) String() string

type Value

type Value interface {
	String() string
	ByteSlice() []byte
}

Jump to

Keyboard shortcuts

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