data

package
v2.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package data implements on disk and in memory storage for data files

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAndRecover

func CheckAndRecover(path string, cfg *config.Config) error

CheckAndRecover checks and recovers the last datafile. If the datafile isn't corrupted, this is a noop. If it is, the longest non-corrupted prefix will be kept and the rest will be *deleted*. Also, the index file is also *deleted* which will be automatically recreated on next startup.

Types

type Datafile

type Datafile interface {
	FileID() int
	Name() string
	Close() error
	Sync() error
	Size() int64
	Read() (internal.Entry, int64, error)
	ReadAt(index, size int64) (internal.Entry, error)
	Write(internal.Entry) (int64, int64, error)
	Readonly() Datafile
}

Datafile is an interface that represents a readable and writeable datafile

func NewInMemoryDatafile

func NewInMemoryDatafile(id int, maxKeySize uint32, maxValueSize uint64) Datafile

NewInMemoryDatafile creates a new in-memory datafile

func NewOnDiskDatafile

func NewOnDiskDatafile(path string, id int, readonly bool, maxKeySize uint32, maxValueSize uint64, fileMode os.FileMode) (Datafile, error)

NewOnDiskDatafile opens an existing on disk datafile

Jump to

Keyboard shortcuts

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