Versions in this module Expand all Collapse all v1 v1.0.0 Dec 18, 2022 Changes in this version + const HINTS_FILE + const LOCKFILE + const MaxKeySize + const MaxValueSize + var ErrChecksumMismatch = errors.New("invalid data: checksum does not match") + var ErrEmptyKey = errors.New("invalid key: key cannot be empty") + var ErrExpiredKey = errors.New("invalid key: key is already expired") + var ErrLargeKey = errors.New("invalid key: size cannot be more than 4294967296 bytes") + var ErrLargeValue = errors.New("invalid value: size cannot be more than 4294967296 bytes") + var ErrLocked = errors.New("a lockfile already exists") + var ErrNoKey = errors.New("invalid key: key is either deleted or expired or unset") + var ErrReadOnly = errors.New("operation not allowed in read only mode") + type Barrel struct + func Init(cfg ...Config) (*Barrel, error) + func (b *Barrel) Delete(k string) error + func (b *Barrel) ExamineFileSize(evalInterval time.Duration) + func (b *Barrel) Fold(fn func(k string) error) error + func (b *Barrel) Get(k string) ([]byte, error) + func (b *Barrel) Len() int + func (b *Barrel) List() []string + func (b *Barrel) Put(k string, val []byte) error + func (b *Barrel) PutEx(k string, val []byte, ex time.Duration) error + func (b *Barrel) RunCompaction(evalInterval time.Duration) + func (b *Barrel) Shutdown() error + func (b *Barrel) Sync() error + func (b *Barrel) SyncFile(evalInterval time.Duration) + type Config func(*Options) error + func WithAlwaysSync() Config + func WithAutoSync() Config + func WithBackgrondSync(interval time.Duration) Config + func WithCheckFileSizeInterval(interval time.Duration) Config + func WithCompactInterval(interval time.Duration) Config + func WithDebug() Config + func WithDir(dir string) Config + func WithMaxActiveFileSize(size int64) Config + func WithReadOnly() Config + type Header struct + Checksum uint32 + Expiry uint32 + KeySize uint32 + Timestamp uint32 + ValSize uint32 + type KeyDir map[string]Meta + func (k *KeyDir) Decode(fPath string) error + func (k *KeyDir) Encode(fPath string) error + type Meta struct + FileID int + RecordPos int + RecordSize int + Timestamp int + type Options struct + func DefaultOptions() *Options + type Record struct + Header Header + Key string + Value []byte