database

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2022 License: GPL-3.0 Imports: 0 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const IdealBatchSize = 100 * 1024

Code using batches should try to add this much data to the batch. The value was determined empirically.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

type Batch interface {
	Putter
	Deleter
	Referencer
	Dereferencer
	ValueSize() int // amount of data in the batch
	Write() error
	// Reset resets the batch for reuse
	Reset()
}

Batch is a write-only database that commits changes to its host database when Write is called. Batch cannot be used concurrently.

type Database

type Database interface {
	Putter
	Deleter
	Referencer
	Dereferencer
	Get(key []byte) ([]byte, error)
	Has(key []byte) (bool, error)
	CountReference(key []byte) (int, error)
	Close()
	NewBatch() Batch
}

Database wraps all database operations. All methods are safe for concurrent use.

type Deleter

type Deleter interface {
	Delete(key []byte) error
}

Deleter wraps the database delete operation supported by both batches and regular databases.

type Dereferencer

type Dereferencer interface {
	Dereference(key []byte) error
}

Dereferencer wraps the database dereference operation supported by both batches and regular databases.

type Putter

type Putter interface {
	Put(key []byte, value []byte) error
}

Putter wraps the database write operation supported by both batches and regular databases.

type Referencer

type Referencer interface {
	Reference(key []byte) error
}

Referencer wraps the database reference operation supported by both batches and regular databases.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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