mem

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Storage

type Storage struct {

	// SyncCount number of `Sync` method called
	SyncCount uint64
	// contains filtered or unexported fields
}

Storage memory storage

func NewStorage

func NewStorage(fs vfs.FS) *Storage

NewStorage returns a mem data storage with snapshot data backed by the specified vfs

func (*Storage) ApplySnapshot

func (s *Storage) ApplySnapshot(path string) error

ApplySnapshot apply a snapshort file from giving path

func (*Storage) BatchDelete

func (s *Storage) BatchDelete(keys ...[]byte) error

BatchDelete batch delete

func (*Storage) BatchSet

func (s *Storage) BatchSet(pairs ...[]byte) error

BatchSet batch set

func (*Storage) Close

func (s *Storage) Close() error

Close close the storage

func (*Storage) CreateSnapshot

func (s *Storage) CreateSnapshot(path string, start, end []byte) error

CreateSnapshot create a snapshot file under the giving path

func (*Storage) Delete

func (s *Storage) Delete(key []byte) error

Delete remove the key from the storage

func (*Storage) Free

func (s *Storage) Free(pooled []byte)

Free free the pooled bytes

func (*Storage) Get

func (s *Storage) Get(key []byte) ([]byte, error)

Get returns the value of the key

func (*Storage) MGet

func (s *Storage) MGet(keys ...[]byte) ([][]byte, error)

MGet returns multi values

func (*Storage) PrefixScan

func (s *Storage) PrefixScan(prefix []byte, handler func(key, value []byte) (bool, error), pooledKey bool) error

PrefixScan scans the key-value pairs starts from prefix but only keys for the same prefix, while perform with a handler function, if the function returns false, the scan will be terminated. if the `pooledKey` is true, raftstore will call `Free` when scan completed.

func (*Storage) RangeDelete

func (s *Storage) RangeDelete(start, end []byte) error

RangeDelete remove data in [start,end)

func (*Storage) RemoveShardData

func (s *Storage) RemoveShardData(shard bhmetapb.Shard, encodedStartKey, encodedEndKey []byte) error

RemoveShardData remove shard data

func (*Storage) Scan

func (s *Storage) Scan(start, end []byte, handler func(key, value []byte) (bool, error), pooledKey bool) error

Scan scans the key-value paire in [start, end), and perform with a handler function, if the function returns false, the scan will be terminated, if the `pooledKey` is true, raftstore will call `Free` when scan completed.

func (*Storage) Seek

func (s *Storage) Seek(key []byte) ([]byte, []byte, error)

Seek returns the first key-value that >= key

func (*Storage) Set

func (s *Storage) Set(key []byte, value []byte) error

Set put the key, value pair to the storage

func (*Storage) SetWithTTL

func (s *Storage) SetWithTTL(key []byte, value []byte, ttl int32) error

SetWithTTL put the key, value pair to the storage with a ttl in seconds

func (*Storage) SplitCheck

func (s *Storage) SplitCheck(start []byte, end []byte, size uint64) (uint64, uint64, [][]byte, error)

SplitCheck Find a key from [start, end), so that the sum of bytes of the value of [start, key) <=size, returns the current bytes in [start,end), and the founded key

func (*Storage) Stats

func (s *Storage) Stats() stats.Stats

func (*Storage) Sync

func (s *Storage) Sync() error

Sync sync data

func (*Storage) Write

func (s *Storage) Write(wb *util.WriteBatch, sync bool) error

Write write the data in batch

Jump to

Keyboard shortcuts

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