storage

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2014 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const LEVELDB_NAME = "leveldb"
View Source
const MDB_NAME = "lmdb"

Variables

This section is empty.

Functions

func DefaultPredicate

func DefaultPredicate(last []byte) func(key []byte) bool

func NewLevelDBConfig

func NewLevelDBConfig() interface{}

func NewMDBConfiguration

func NewMDBConfiguration() interface{}

func RegisterEngine added in v0.8.6

func RegisterEngine(name string, init Initializer) error

Types

type Engine

type Engine interface {
	Name() string
	Path() string
	// Add the given key/value pair, duplicates aren't allowed
	Put(key, value []byte) error
	// Get the value associated with the given key
	Get(key []byte) ([]byte, error)
	// More efficient put
	BatchPut(writes []Write) error
	// Delete the given range of keys [first, last]
	Del(first, last []byte) error
	// Get an iterator for the db
	Iterator() Iterator
	// Compact the db and reclaim unused space
	Compact()
	// Close the database
	Close()
}

Interface to all storage engine backends

func NewLevelDB

func NewLevelDB(path string, config interface{}) (Engine, error)

func NewMDB

func NewMDB(path string, config interface{}) (Engine, error)

type Initializer

type Initializer struct {
	NewConfig  func() interface{}
	Initialize func(path string, config interface{}) (Engine, error)
}

func GetInitializer

func GetInitializer(name string) (Initializer, error)

type Iterator

type Iterator interface {
	// Seek to the given key, or a larger key if this one doesn't exist
	Seek(key []byte)
	// Get the key at the current position
	Key() []byte
	// Get the value at the current position
	Value() []byte
	// Move the next element
	Next()
	// Move the previous element
	Prev()
	// True if no error occured during scanning and if the predicate
	// used when calling GetRangePredicate is true . If GetRange is
	// used, returns GetKey() <= last where <= is the lexicographic
	// order.
	Valid() bool
	// Returns any errors occured during scannig
	Error() error
	// Close the iterator and free the resources used
	Close() error
}

Iterator is used to scan a range of keys

type LevelDB

type LevelDB struct {
	// contains filtered or unexported fields
}

func (LevelDB) BatchPut

func (db LevelDB) BatchPut(writes []Write) error

func (LevelDB) Close

func (db LevelDB) Close()

func (LevelDB) Compact

func (db LevelDB) Compact()

func (LevelDB) Del

func (db LevelDB) Del(start, finish []byte) error

func (LevelDB) Get

func (db LevelDB) Get(key []byte) ([]byte, error)

func (LevelDB) Iterator

func (db LevelDB) Iterator() Iterator

func (LevelDB) Name

func (_ LevelDB) Name() string

func (LevelDB) Path

func (db LevelDB) Path() string

func (LevelDB) Put

func (db LevelDB) Put(key, value []byte) error

type LevelDbConfiguration

type LevelDbConfiguration struct {
	MaxOpenFiles int                `toml:"max-open-files"`
	LruCacheSize configuration.Size `toml:"lru-cache-size"`
}

type LevelDbIterator

type LevelDbIterator struct {
	// contains filtered or unexported fields
}

func (*LevelDbIterator) Close

func (itr *LevelDbIterator) Close() error

func (*LevelDbIterator) Error

func (itr *LevelDbIterator) Error() error

func (*LevelDbIterator) Key

func (itr *LevelDbIterator) Key() []byte

func (*LevelDbIterator) Next

func (itr *LevelDbIterator) Next()

func (*LevelDbIterator) Prev

func (itr *LevelDbIterator) Prev()

func (*LevelDbIterator) Seek

func (itr *LevelDbIterator) Seek(key []byte)

func (*LevelDbIterator) Valid

func (itr *LevelDbIterator) Valid() bool

func (*LevelDbIterator) Value

func (itr *LevelDbIterator) Value() []byte

type MDB

type MDB struct {
	// contains filtered or unexported fields
}

func (MDB) BatchPut

func (db MDB) BatchPut(writes []Write) error

func (MDB) Close

func (db MDB) Close()

func (MDB) Compact

func (db MDB) Compact()

func (MDB) Del

func (db MDB) Del(start, finish []byte) error

func (MDB) Get

func (db MDB) Get(key []byte) ([]byte, error)

func (MDB) Iterator

func (db MDB) Iterator() Iterator

func (MDB) Name

func (_ MDB) Name() string

func (MDB) Path

func (db MDB) Path() string

func (MDB) Put

func (db MDB) Put(key, value []byte) error

type MDBConfiguration

type MDBConfiguration struct {
	MapSize configuration.Size `toml:"map-size"`
}

type MDBIterator

type MDBIterator struct {
	// contains filtered or unexported fields
}

func (*MDBIterator) Close

func (itr *MDBIterator) Close() error

func (*MDBIterator) Error

func (itr *MDBIterator) Error() error

func (*MDBIterator) Key

func (itr *MDBIterator) Key() []byte

func (*MDBIterator) Next

func (itr *MDBIterator) Next()

func (*MDBIterator) Prev

func (itr *MDBIterator) Prev()

func (*MDBIterator) Seek

func (itr *MDBIterator) Seek(key []byte)

func (*MDBIterator) Valid

func (itr *MDBIterator) Valid() bool

func (*MDBIterator) Value

func (itr *MDBIterator) Value() []byte

type Write

type Write struct {
	Key   []byte
	Value []byte
}

A write/delete used by BatchPut. To delete data, set the Value to nil

Jump to

Keyboard shortcuts

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