memkv

package
v0.10.3-0...-9f1054c Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 10 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(ctx context.Context, key string) string

Get return value if key exists, or return empty string

func (*MemoryKV) Has

func (kv *MemoryKV) Has(ctx context.Context, key string) (bool, error)

func (*MemoryKV) HasPrefix

func (kv *MemoryKV) HasPrefix(ctx context.Context, prefix string) (bool, error)

func (*MemoryKV) Load

func (kv *MemoryKV) Load(ctx context.Context, key string) (string, error)

Load loads an object with @key.

func (*MemoryKV) LoadBytes

func (kv *MemoryKV) LoadBytes(ctx context.Context, key string) ([]byte, error)

LoadBytes loads an object with @key.

func (*MemoryKV) LoadBytesRange

func (kv *MemoryKV) LoadBytesRange(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, key string) ([]string, [][]byte, error)

LoadBytesWithPrefix returns all keys & values with given prefix.

func (*MemoryKV) LoadWithPrefix

func (kv *MemoryKV) LoadWithPrefix(ctx context.Context, key string) ([]string, []string, error)

LoadWithPrefix returns all keys & values with given prefix.

func (*MemoryKV) MaxTxnOps

func (kv *MemoryKV) MaxTxnOps() int

MaxTxnOps reports no practical limit: every write is applied under the lock, so any batch commits "atomically" in one shot.

func (*MemoryKV) MultiLoad

func (kv *MemoryKV) MultiLoad(ctx context.Context, keys []string) ([]string, error)

MultiLoad loads objects with multi @keys.

func (*MemoryKV) MultiLoadBytes

func (kv *MemoryKV) MultiLoadBytes(ctx context.Context, keys []string) ([][]byte, error)

MultiLoadBytes loads objects with multi @keys.

func (*MemoryKV) MultiRemove

func (kv *MemoryKV) MultiRemove(ctx context.Context, keys []string) error

MultiRemove removes given @keys in MemoryKV atomicly.

func (*MemoryKV) MultiSave

func (kv *MemoryKV) MultiSave(ctx context.Context, kvs map[string]string) error

MultiSave saves given key-value pairs in MemoryKV atomicly.

func (*MemoryKV) MultiSaveAndRemove

func (kv *MemoryKV) MultiSaveAndRemove(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, kvs map[string][]byte) error

MultiSaveBytes saves given key-value pairs in MemoryKV atomicly.

func (*MemoryKV) MultiSaveBytesAndRemove

func (kv *MemoryKV) MultiSaveBytesAndRemove(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, key string) error

Remove deletes an object with @key.

func (*MemoryKV) RemoveWithPrefix

func (kv *MemoryKV) RemoveWithPrefix(ctx context.Context, key string) error

RemoveWithPrefix remove key of given prefix in MemoryKV atomicly.

func (*MemoryKV) Save

func (kv *MemoryKV) Save(ctx context.Context, key, value string) error

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

func (*MemoryKV) SaveBytes

func (kv *MemoryKV) SaveBytes(ctx context.Context, key string, value []byte) error

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

func (*MemoryKV) WalkWithPrefix

func (kv *MemoryKV) WalkWithPrefix(ctx context.Context, prefix string, _ int, fn func([]byte, []byte) error) error

WalkWithPrefix visits matching entries in key order until the callback returns an error. paginationSize is irrelevant for the in-memory store.

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
⌂ 换网址