lockstore

package
v1.1.0-beta.0...-2ca497e Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hint

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

Hint represents a hint.

type Iterator

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

Iterator iterates the entries in the MemStore.

func (*Iterator) Key

func (it *Iterator) Key() []byte

Key returns the key at the current position.

func (*Iterator) Next

func (it *Iterator) Next()

Next moves the iterator to the next entry.

func (*Iterator) Prev

func (it *Iterator) Prev()

Prev moves the iterator to the previous entry.

func (*Iterator) Seek

func (it *Iterator) Seek(seekKey []byte)

Seek locates the iterator to the first entry with a key >= seekKey.

func (*Iterator) SeekForExclusivePrev

func (it *Iterator) SeekForExclusivePrev(target []byte)

SeekForExclusivePrev locates the iterator to the last entry with key < target.

func (*Iterator) SeekForPrev

func (it *Iterator) SeekForPrev(target []byte)

SeekForPrev locates the iterator to the last entry with key <= target.

func (*Iterator) SeekToFirst

func (it *Iterator) SeekToFirst()

SeekToFirst locates the iterator to the first entry.

func (*Iterator) SeekToLast

func (it *Iterator) SeekToLast()

SeekToLast locates the iterator to the last entry.

func (*Iterator) Valid

func (it *Iterator) Valid() bool

Valid returns true iff the iterator is positioned at a valid node.

func (*Iterator) Value

func (it *Iterator) Value() []byte

Value returns value.

type MemStore

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

MemStore is a skiplist variant used to store lock. Compares to normal skip list, it only supports single thread write. But it can reuse the memory, so that the memory usage doesn't keep growing.

func NewMemStore

func NewMemStore(arenaBlockSize int) *MemStore

NewMemStore returns a new mem store.

func (*MemStore) Delete

func (ls *MemStore) Delete(key []byte) bool

Delete deletes a value with the key.

func (*MemStore) DeleteWithHint

func (ls *MemStore) DeleteWithHint(key []byte, hint *Hint) bool

DeleteWithHint deletes a value with the key and hint.

func (*MemStore) DumpToFile

func (ls *MemStore) DumpToFile(fileName string, meta []byte) error

DumpToFile dumps the meta to a file

func (*MemStore) Get

func (ls *MemStore) Get(key, buf []byte) []byte

Get gets a value with the key.

func (*MemStore) Len

func (ls *MemStore) Len() int

Len returns the length of a mem store.

func (*MemStore) LoadFromFile

func (ls *MemStore) LoadFromFile(fileName string) (meta []byte, err error)

LoadFromFile load a meta from a file.

func (*MemStore) NewIterator

func (ls *MemStore) NewIterator() *Iterator

NewIterator returns a new Iterator for the lock store.

func (*MemStore) Put

func (ls *MemStore) Put(key []byte, v []byte) bool

Put puts the key-value pair, returns true if the key doesn't exist.

func (*MemStore) PutWithHint

func (ls *MemStore) PutWithHint(key []byte, v []byte, hint *Hint) bool

PutWithHint puts the key-value pair, returns true if the key doesn't exist.

Jump to

Keyboard shortcuts

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