mutcask

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HintDeletedFlag = byte(1)
)
View Source
const HintEncodeSize = HintKeySize + 8 + 4

HintKeySize + 8 bytes value offset + 4 bytes value size

View Source
const HintKeySize = MaxKeySize + 1 + 1

max key size 128 byte + 1 byte which record the key size + 1 byte delete flag

View Source
const MaxKeySize = 128

Variables

View Source
var (
	ErrNone                = xerrors.New("mutcask: error none")
	ErrValueFormat         = xerrors.New("mutcask: invalid value format")
	ErrDataRotted          = xerrors.New("mutcask: data may be rotted")
	ErrKeySizeTooLong      = xerrors.New("mutcask: key size is too long")
	ErrHintFormat          = xerrors.New("mutcask: invalid hint format")
	ErrPathUndefined       = xerrors.New("mutcask: should define path within config")
	ErrPath                = xerrors.New("mutcask: path should be directory not file")
	ErrHintLogBroken       = xerrors.New("mutcask: hint log broken")
	ErrReadHintBeyondRange = xerrors.New("mutcask: read hint out of file range")
	ErrRepoLocked          = xerrors.New("mutcask: repo has been locked")
)

Functions

func DecodeValue

func DecodeValue(buf []byte, verify bool) (v []byte, err error)

func EncodeValue

func EncodeValue(v []byte) (ret []byte)

*

crc32	:	value
4 		: 	xxxx

*

func NewMutcask

func NewMutcask(opts ...Option) (*mutcask, error)

Types

type Cask

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

func NewCask

func NewCask(id uint32) *Cask

func (*Cask) Close

func (c *Cask) Close()

func (*Cask) Delete

func (c *Cask) Delete(key string) (err error)

func (*Cask) Put

func (c *Cask) Put(key string, value []byte) (err error)

func (*Cask) Read

func (c *Cask) Read(key string) (v []byte, err error)

func (*Cask) Size

func (c *Cask) Size(key string) (int, error)

type CaskMap

type CaskMap struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*CaskMap) Add

func (cm *CaskMap) Add(id uint32, cask *Cask)

func (*CaskMap) CloseAll

func (cm *CaskMap) CloseAll()

func (*CaskMap) Get

func (cm *CaskMap) Get(id uint32) (c *Cask, b bool)

type Config

type Config struct {
	Path    string
	CaskNum uint32
}

type Hint

type Hint struct {
	Key     string
	KOffset uint64
	VOffset uint64
	VSize   uint32
	Deleted bool
}

func (*Hint) Encode

func (h *Hint) Encode() (ret []byte, err error)

*

key		:	value offset	:	value size
128+1   :   8   			:   4

*

func (*Hint) From

func (h *Hint) From(buf []byte) (err error)

type KeyMap

type KeyMap struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*KeyMap) Add

func (km *KeyMap) Add(key string, hint *Hint)

func (*KeyMap) Get

func (km *KeyMap) Get(key string) (h *Hint, b bool)

type Option

type Option func(cfg *Config)

func CaskNumConf

func CaskNumConf(caskNum int) Option

func PathConf

func PathConf(dir string) Option

Jump to

Keyboard shortcuts

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