datafile

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ACTIVE_DATAFILE = "barrel_%d.db"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DataFile

type DataFile struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New(dir string, index int) (*DataFile, error)

New initialises a db store for storing/reading an active db file. At a given time only one file can be active.

func (*DataFile) Close

func (d *DataFile) Close() error

Close closes the file descriptors of the underlying db file.

func (*DataFile) ID

func (d *DataFile) ID() int

ID returns the ID of the datafile.

func (*DataFile) Read

func (d *DataFile) Read(pos int, size int) ([]byte, error)

func (*DataFile) Size

func (d *DataFile) Size() (int64, error)

Size returns the size of DB file in bytes.

func (*DataFile) Sync

func (d *DataFile) Sync() error

Sync flushes the in-memory buffers to the disk.

func (*DataFile) Write

func (d *DataFile) Write(data []byte) (int, error)

Write writes the record to the underlying db file.

Jump to

Keyboard shortcuts

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