peach

package module
v0.0.0-...-aa1b12e Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

README

peach

A simple kv database based on bitcask and adaptive radix tree

Documentation

Index

Constants

View Source
const (
	LockFileName = "LOCK"
)
View Source
const (
	LogFileNamePrefix = "log."
)

Variables

View Source
var (
	ErrLogFileNotExist = errors.New("log file not exist")
	ErrKeyNotFound     = errors.New("key not found")
)
View Source
var (
	ErrRawSizeTooShort  = errors.New("raw data size too short to decode")
	ErrCheckSumNotMatch = errors.New("crc check sum not match")
)

Functions

func Encode

func Encode(le *LogEntry) []byte

Types

type DB

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

func New

func New(opts *Options) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) Delete

func (db *DB) Delete(key []byte) error

func (*DB) Get

func (db *DB) Get(key []byte) ([]byte, error)

func (*DB) Put

func (db *DB) Put(key, value []byte) error

func (*DB) Size

func (db *DB) Size() int64

func (*DB) Sync

func (db *DB) Sync() error

type FileLock

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

func NewFlock

func NewFlock(path string) *FileLock

func (*FileLock) TryLock

func (fl *FileLock) TryLock() error

func (*FileLock) ULock

func (fl *FileLock) ULock() error

type LogEntry

type LogEntry struct {
	Type      LogEntryType
	Timestamp int64
	Key       []byte
	Value     []byte
}

func Decode

func Decode(raw []byte) (*LogEntry, error)

type LogEntryType

type LogEntryType uint8
const (
	MaxLogEntryHeaderSize = 25

	Normal LogEntryType = iota + 1
	Delete
	ExpiredAt
)

type LogFile

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

func NewLogFile

func NewLogFile(dirPath string, fid int) (*LogFile, error)

func (*LogFile) Close

func (f *LogFile) Close() error

func (*LogFile) FID

func (f *LogFile) FID() int

func (*LogFile) Load

func (f *LogFile) Load(offset int64) (*LogEntry, int, error)

func (*LogFile) Path

func (f *LogFile) Path() string

func (*LogFile) Read

func (f *LogFile) Read(offset int64, size int) (*LogEntry, error)

func (*LogFile) Size

func (f *LogFile) Size() (int64, error)

func (*LogFile) Sync

func (f *LogFile) Sync() error

func (*LogFile) Write

func (f *LogFile) Write(offset int64, le *LogEntry) (int, error)

type Options

type Options struct {
	DBPath string

	LogFileGCInterval    time.Duration
	LogFileSizeThreshold int64

	ArtOpt *index.AdaptiveRadixTreeOptions
}

func DefaultOptions

func DefaultOptions(dbPath string) *Options

Directories

Path Synopsis
art

Jump to

Keyboard shortcuts

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