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 ¶
- func DefaultConfig() *storage.Config
- type KVStore
- func (k *KVStore) Check(hkey uint64) bool
- func (k *KVStore) Close() error
- func (k *KVStore) Compaction() (bool, error)
- func (k *KVStore) Delete(hkey uint64) error
- func (k *KVStore) Destroy() error
- func (k *KVStore) Fork(c *storage.Config) (storage.Engine, error)
- func (k *KVStore) Get(hkey uint64) (storage.Entry, error)
- func (k *KVStore) GetKey(hkey uint64) (string, error)
- func (k *KVStore) GetLastAccess(hkey uint64) (int64, error)
- func (k *KVStore) GetRaw(hkey uint64) ([]byte, error)
- func (k *KVStore) GetTTL(hkey uint64) (int64, error)
- func (k *KVStore) Import(data []byte, f func(uint64, storage.Entry) error) error
- func (k *KVStore) Name() string
- func (k *KVStore) NewEntry() storage.Entry
- func (k *KVStore) Put(hkey uint64, value storage.Entry) error
- func (k *KVStore) PutRaw(hkey uint64, value []byte) error
- func (k *KVStore) Range(f func(hkey uint64, e storage.Entry) bool)
- func (k *KVStore) RangeHKey(f func(hkey uint64) bool)
- func (k *KVStore) Scan(cursor uint64, count int, f func(e storage.Entry) bool) (uint64, error)
- func (k *KVStore) ScanRegexMatch(cursor uint64, expr string, count int, f func(e storage.Entry) bool) (uint64, error)
- func (k *KVStore) SetConfig(c *storage.Config)
- func (k *KVStore) SetLogger(_ *log.Logger)
- func (k *KVStore) Start() error
- func (k *KVStore) Stats() storage.Stats
- func (k *KVStore) TransferIterator() storage.TransferIterator
- func (k *KVStore) UpdateTTL(hkey uint64, data storage.Entry) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultConfig ¶
Types ¶
type KVStore ¶
type KVStore struct {
// contains filtered or unexported fields
}
KVStore implements an in-memory storage engine.
func (*KVStore) Compaction ¶
func (*KVStore) Delete ¶
Delete deletes the value for the given key. Delete will not returns error if key doesn't exist.
func (*KVStore) Get ¶
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 ¶
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 (*KVStore) GetRaw ¶
GetRaw extracts encoded value for the given hkey. This is useful for merging tables.
func (*KVStore) GetTTL ¶
GetTTL gets the timeout for the given key. It returns storage.ErrKeyNotFound if the DB does not contain the key.
func (*KVStore) Put ¶
Put sets the value for the given key. It overwrites any previous value for that key
func (*KVStore) Range ¶
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
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) ScanRegexMatch ¶ added in v0.5.0
func (*KVStore) 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