kvstore

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package kvstore implements a GC friendly in-memory storage engine by using built-in maps and byte slices. It also supports compaction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConfig

func DefaultConfig() *storage.Config

Types

type KVStore

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

KVStore implements an in-memory storage engine.

func New added in v0.5.0

func New(c *storage.Config) (*KVStore, error)

func (*KVStore) Check

func (k *KVStore) Check(hkey uint64) bool

Check checks the key existence.

func (*KVStore) Close

func (k *KVStore) Close() error

func (*KVStore) Compaction

func (k *KVStore) Compaction() (bool, error)

func (*KVStore) Delete

func (k *KVStore) Delete(hkey uint64) error

Delete deletes the value for the given key. Delete will not returns error if key doesn't exist.

func (*KVStore) Destroy

func (k *KVStore) Destroy() error

func (*KVStore) Fork

func (k *KVStore) Fork(c *storage.Config) (storage.Engine, error)

Fork creates a new KVStore instance.

func (*KVStore) Get

func (k *KVStore) Get(hkey uint64) (storage.Entry, error)

Get gets the value for the given key. It returns storage.ErrKeyNotFound if the DB does not contain the key. The returned Entry is its own copy, it is safe to modify the contents of the returned slice.

func (*KVStore) GetKey

func (k *KVStore) GetKey(hkey uint64) (string, error)

GetKey gets the key for the given hkey. It returns storage.ErrKeyNotFound if the DB does not contain the key.

func (*KVStore) GetLastAccess added in v0.5.0

func (k *KVStore) GetLastAccess(hkey uint64) (int64, error)

func (*KVStore) GetRaw

func (k *KVStore) GetRaw(hkey uint64) ([]byte, error)

GetRaw extracts encoded value for the given hkey. This is useful for merging tables.

func (*KVStore) GetTTL

func (k *KVStore) GetTTL(hkey uint64) (int64, error)

GetTTL gets the timeout for the given key. It returns storage.ErrKeyNotFound if the DB does not contain the key.

func (*KVStore) Import

func (k *KVStore) Import(data []byte, f func(uint64, storage.Entry) error) error

func (*KVStore) Name

func (k *KVStore) Name() string

func (*KVStore) NewEntry

func (k *KVStore) NewEntry() storage.Entry

func (*KVStore) Put

func (k *KVStore) Put(hkey uint64, value storage.Entry) error

Put sets the value for the given key. It overwrites any previous value for that key

func (*KVStore) PutRaw

func (k *KVStore) PutRaw(hkey uint64, value []byte) error

PutRaw sets the raw value for the given key.

func (*KVStore) Range

func (k *KVStore) Range(f func(hkey uint64, e storage.Entry) bool)

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration. Range may be O(N) with the number of elements in the map even if f returns false after a constant number of calls.

func (*KVStore) RangeHKey added in v0.5.0

func (k *KVStore) RangeHKey(f func(hkey uint64) bool)

RangeHKey calls f sequentially for each key present in the map. If f returns false, range stops the iteration. Range may be O(N) with the number of elements in the map even if f returns false after a constant number of calls.

func (*KVStore) Scan added in v0.5.0

func (k *KVStore) Scan(cursor uint64, count int, f func(e storage.Entry) bool) (uint64, error)

func (*KVStore) ScanRegexMatch added in v0.5.0

func (k *KVStore) ScanRegexMatch(cursor uint64, expr string, count int, f func(e storage.Entry) bool) (uint64, error)

func (*KVStore) SetConfig

func (k *KVStore) SetConfig(c *storage.Config)

func (*KVStore) SetLogger

func (k *KVStore) SetLogger(_ *log.Logger)

func (*KVStore) Start

func (k *KVStore) Start() error

func (*KVStore) Stats

func (k *KVStore) Stats() storage.Stats

Stats is a function which provides memory allocation and garbage ratio of a storage instance.

func (*KVStore) TransferIterator added in v0.5.0

func (k *KVStore) TransferIterator() storage.TransferIterator

func (*KVStore) UpdateTTL

func (k *KVStore) UpdateTTL(hkey uint64, data storage.Entry) error

UpdateTTL updates the expiry for the given key.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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