levelup

package module
v0.0.0-...-ed45df3 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2017 License: ISC Imports: 0 Imported by: 10

README

levelup

This package implements a few types and interfaces to be used by the actual "down" libraries, which will implement the core functionality of each database.

Some of the "down" libraries implementing the "up" interface:

Any similarity with the Node.js LevelUP is mere coincidence.

some things:
  • When the value for some key is "" or blank or not found, NotFound will be returned.
  • RangeOpts treats go zero values as if you didn't pass anything, so Limit: 0 is the same as no limit, Start: "" is the same as no start etc.
  • In RangeOpts Start is inclusive, End is non-inclusive.
  • All keys and values are []byte, if you want to use strings, see github.com/fiatjaf/levelup/stringlevelup.

traffic analytics for this repo:

Documentation

Index

Constants

View Source
const (
	NotFound = Error("levelup: not found")
)

Variables

View Source
var (
	DefaultRangeLimit = 9999999
	DefaultRangeEnd   = []byte{0xff, 0xff, 0xff, 0xff, 0xff}
)
View Source
var BatchDel = Del
View Source
var BatchPut = Put

Functions

This section is empty.

Types

type DB

type DB interface {
	Close()
	Erase()
	Put([]byte, []byte) error
	Get([]byte) ([]byte, error)
	Del([]byte) error
	Batch([]Operation) error
	ReadRange(*RangeOpts) ReadIterator
}

type Error

type Error string

func (Error) Error

func (e Error) Error() string

type Operation

type Operation struct {
	Type  string
	Key   []byte
	Value []byte
}

func Del

func Del(key []byte) Operation

func Put

func Put(key, value []byte) Operation

type RangeOpts

type RangeOpts struct {
	Start   []byte // included, default []byte{}
	End     []byte // not included, default []byte{0xff, 0xff, 0xff, 0xff, 0xff}
	Reverse bool   // default false
	Limit   int    // default 9999999
}

func (*RangeOpts) FillDefaults

func (ro *RangeOpts) FillDefaults()

type ReadIterator

type ReadIterator interface {
	Valid() bool   // returns false when we have reached the end of the rows we asked for.
	Next()         // go to the next row.
	Key() []byte   // the key in the current row.
	Value() []byte // the value in the current row.
	Error() error  // if some error has happened this have it.
	Release()      // it may be necessary to call this after using, or defer it.
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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