ezdb

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

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

Go to latest
Published: Mar 29, 2017 License: MIT Imports: 5 Imported by: 0

README

ezdb

Build Status Go Report Card GoDoc

ezdb is a Golang package which makes it easy to operate on leveldb(open / close, put / get keys, go through keys) based on levigo.

Documentation
License

Documentation

Overview

Package ezdb provides the functions to make it easy to use levigo to interact golang apps with leveldb.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DEBUG is debug mode.
	// Set this flag to true to output debug messages from this package.
	DEBUG = false
)

Functions

func IsIteratorValidForGoThrough

func IsIteratorValidForGoThrough(it *levigo.Iterator, keyEnd string) bool

IsIteratorValidForGoThrough checks if current iterator is valid while go through the db.

Types

type DB

type DB struct {
	LevigoDB *levigo.DB // Instance of levigo.DB
	// contains filtered or unexported fields
}

DB is a wrapper of levigo.DB.

func Open

func Open(dbPath string, cacheSize int) (db *DB, err error)

Open opens a leveldb database.

func (*DB) Close

func (db *DB) Close()

Close closes the leveldb database after use.

func (*DB) Delete

func (db *DB) Delete(key []byte) (err error)

Delete is a wrapper for levigo.DB.Delete()

func (*DB) DeleteStr

func (db *DB) DeleteStr(key string) (err error)

DeleteStr delete the string key.

func (*DB) Get

func (db *DB) Get(key []byte) (value []byte, err error)

Get is a wrapper for levigo.DB.Get().

func (*DB) GetInt64

func (db *DB) GetInt64(key string) (value int64, err error)

GetInt64 get string value and convert it to int64. It should be used with PutInt64().

func (*DB) GetStr

func (db *DB) GetStr(key string) (value string, err error)

GetStr gets the key / value as string value.

func (*DB) GetUint64

func (db *DB) GetUint64(key string) (value uint64, err error)

GetUint64 get string value and convert it to uint64. It should be used with PutUInt64().

func (*DB) GoThrough

func (db *DB) GoThrough(keyStart, keyEnd string, processor GoThroughProcessor) (err error)

GoThrough goes through the leveldb db and call the GoThroughProcessor.Process() to process data.

func (*DB) KeyExist

func (db *DB) KeyExist(key string) (exist bool, err error)

KeyExist checks if key exists or not.

func (*DB) NewIterator

func (db *DB) NewIterator() *levigo.Iterator

NewIterator creates a new iterator of levigo.

func (*DB) Put

func (db *DB) Put(key, value []byte) (err error)

Put is a wrapper for levigo.DB.Put().

func (*DB) PutInt64

func (db *DB) PutInt64(key string, value int64) (err error)

PutInt64 stores int64 as string in db. It should be used with Getint64().

func (*DB) PutStr

func (db *DB) PutStr(key, value string) (err error)

PutStr puts the key / value as string value.

func (*DB) PutUint64

func (db *DB) PutUint64(key string, value uint64) (err error)

PutUint64 store uint64 as string in db. It should be used with GetUint64().

type GoThroughProcessor

type GoThroughProcessor interface {
	Process(k, v string) error
}

GoThroughProcessor provides the interface to process leveldb record while go through the leveldb database.

Jump to

Keyboard shortcuts

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