emssdb

package module
v0.0.0-...-0fa4a08 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2017 License: BSD-3-Clause Imports: 10 Imported by: 0

README

Emssdb

A embedded ssdb. It is just like the libssdb in c++. But this is in golang.

APIS

The apis of emssdb is not completely compatible with libssdb.

Difference

Emssdb is not compatible with libssdb too.

  • The structure of key is not same as libssdb's.
  • The queue of emssdb is different with libssdb's.

Documentation

Index

Constants

View Source
const (
	UINT64_MAX       = 18446744073709551615
	SSDB_SCORE_WIDTH = 9
	SSDB_KEY_LEN_MAX = 255
	SYNCLOG          = 1
	DTKV             = 'k'
	DTEXKV           = 'x'
	DTEXSTAMP        = 'e'
	DTHASH           = 'h' // hashmap(sorted by key)
	DTHSIZE          = 'H'
	DTZSET           = 's' // key => score
	DTZSCORE         = 'z' // key|score => ""
	DTZSIZE          = 'Z'
	DTQUEUE          = 'q'
	DTQSIZE          = 'Q'
	MIN_PREFIX       = DTHASH
	MAX_PREFIX       = DTZSET
)
View Source
const (
	FORWARD  = 0
	BACKWARD = 1
)

Variables

View Source
var (
	ErrNotFound   = errors.New("ssdb: not found")
	ErrEmptyKey   = errors.New("ssdb: empty key")
	ErrLongKey    = errors.New("ssdb: key too long")
	StatSuccess   = errors.New("")
	StatSucChange = errors.New("ssdb: change size")
	StatNotFound  = errors.New("ssdb: no item")
	ErrOptFail    = errors.New("ssdb: operate fail")
	ErrNotIntVal  = errors.New("ssdb: not intager val")
	ErrOutOfRange = errors.New("ssdb: out of range")
	ErrQueue      = errors.New("error queue")
)

Functions

This section is empty.

Types

type B

type B = Bytes

type Bytes

type Bytes []byte

func NewByClone

func NewByClone(bb []byte) (ret Bytes)

NewByClone deep copy a new byte slice

func NewByInt64

func NewByInt64(i int64) (ret Bytes)

NewByInt64 same as NewByUInt64

func NewByUInt64

func NewByUInt64(i uint64) (ret Bytes)

NewByUInt64 by bigendian

func (Bytes) GetInt64

func (b Bytes) GetInt64() (ret int64)

GetInt64 same as GetUInt64

func (Bytes) GetUInt64

func (b Bytes) GetUInt64() (ret uint64)

GetUInt64 to uint64 by the first 8 bytes(bigendian)

type DB

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

DB emssdb DB struct

func OpenDB

func OpenDB(options Options) (that *DB, err error)

OpenDB open a emssdb by options

func (*DB) Close

func (d *DB) Close()

Close close emssdb

func (*DB) Compact

func (d *DB) Compact() (err error)

func (*DB) Del

func (db *DB) Del(key Bytes) (err error)

func (*DB) Edel

func (db *DB) Edel(key Bytes) (err error)

func (*DB) Eget

func (db *DB) Eget(key Bytes) (ret Bytes, stamp uint64, err error)

func (*DB) Elist

func (db *DB) Elist(start uint64, end uint64) (ret *XIterator)

func (*DB) Erscan

func (db *DB) Erscan(start Bytes, end Bytes) (ret *EIterator)

func (*DB) Escan

func (db *DB) Escan(start Bytes, end Bytes) (ret *EIterator)

func (*DB) Eset

func (db *DB) Eset(key, val Bytes, etime uint64) (err error)

func (*DB) EsetDelay

func (db *DB) EsetDelay(delay time.Duration)

func (*DB) Get

func (db *DB) Get(key Bytes) (ret Bytes, err error)

func (*DB) Hdel

func (db *DB) Hdel(name, key Bytes) (err error)

func (*DB) Hget

func (db *DB) Hget(name, key Bytes) (val Bytes, err error)

func (*DB) Hincr

func (db *DB) Hincr(name, key Bytes, by int64) (newval int64, err error)

func (*DB) Hlist

func (db *DB) Hlist(sname, ename Bytes) (ret []Bytes)

func (*DB) Hrscan

func (db *DB) Hrscan(name, start, end Bytes) (ret *HIterator)

func (*DB) Hscan

func (db *DB) Hscan(name, start, end Bytes) (ret *HIterator)

func (*DB) Hset

func (db *DB) Hset(name, key, val Bytes) (err error)

func (*DB) Hsize

func (db *DB) Hsize(name Bytes) (ret int64, err error)

func (*DB) Incr

func (db *DB) Incr(key Bytes, by int64) (newval int64, err error)

func (*DB) Info

func (d *DB) Info() (ret map[string]string)

func (*DB) Iterator

func (d *DB) Iterator(start Bytes, end Bytes) (ret *Iterator)

return (start, end], not include start

func (*DB) KeyRange

func (d *DB) KeyRange(keys []string)

func (*DB) MultiDelete

func (db *DB) MultiDelete(keys []Bytes) (err error)

func (*DB) MultiSet

func (db *DB) MultiSet(keys []Bytes, vals []Bytes) (err error)

func (*DB) Qback

func (db *DB) Qback(name Bytes) (ret Bytes, err error)

func (*DB) Qfront

func (db *DB) Qfront(name Bytes) (ret Bytes, err error)

func (*DB) Qget

func (db *DB) Qget(name Bytes, seq int64) (ret Bytes, err error)

func (*DB) Qlist

func (db *DB) Qlist(sname, ename Bytes) (ret []Bytes)

func (*DB) QpopBack

func (db *DB) QpopBack(name Bytes) (item Bytes, ret error)

func (*DB) QpopFront

func (db *DB) QpopFront(name Bytes) (item Bytes, ret error)

func (*DB) QpushBack

func (db *DB) QpushBack(name, item Bytes) (ret error)

func (*DB) QpushFront

func (db *DB) QpushFront(name, item Bytes) (ret error)

func (*DB) Qscan

func (db *DB) Qscan(name Bytes) (ret *QIterator)

func (*DB) Qsize

func (db *DB) Qsize(name Bytes) (ret int64, err error)

func (*DB) RawDel

func (d *DB) RawDel(key Bytes) (err error)

func (*DB) RawGet

func (d *DB) RawGet(key Bytes) (val Bytes, err error)

func (*DB) RawSet

func (d *DB) RawSet(key Bytes, val Bytes) (err error)

/* raw operates */

// repl: whether to sync d operation to slaves

func (*DB) RevIterator

func (d *DB) RevIterator(start Bytes, end Bytes) (ret *Iterator)

func (*DB) Rscan

func (db *DB) Rscan(start Bytes, end Bytes) (ret *KIterator)

func (*DB) Scan

func (db *DB) Scan(start Bytes, end Bytes) (ret *KIterator)

func (*DB) Set

func (db *DB) Set(key Bytes, val Bytes) (err error)

func (*DB) Zdel

func (db *DB) Zdel(name, key Bytes) (err error)

func (*DB) Zget

func (db *DB) Zget(name, key Bytes) (score int64, err error)

func (*DB) Zincr

func (db *DB) Zincr(name Bytes, key Bytes, by int64) (newval int64, err error)

func (*DB) Zlist

func (db *DB) Zlist(sname, ename Bytes) (ret []Bytes)

func (*DB) Zrscan

func (db *DB) Zrscan(name Bytes, start, end int64) (ret *ZIterator)

func (*DB) Zscan

func (db *DB) Zscan(name Bytes, start, end int64) (ret *ZIterator)

func (*DB) Zset

func (db *DB) Zset(name, key Bytes, score int64) (err error)

func (*DB) Zsize

func (db *DB) Zsize(name Bytes) (ret int64, err error)

type EIterator

type EIterator struct {
	*Iterator
	// contains filtered or unexported fields
}

func NewEIterator

func NewEIterator(it *Iterator) (ret *EIterator)

func (*EIterator) Etime

func (eit *EIterator) Etime() (ret uint64)

func (*EIterator) Next

func (eit *EIterator) Next() (ret bool)

type HIterator

type HIterator struct {
	*Iterator
}

func NewHIterator

func NewHIterator(it *Iterator) (ret *HIterator)

func (*HIterator) Next

func (hit *HIterator) Next() (ret bool)

type Iterator

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

func NewIterator

func NewIterator(it iterator.Iterator, direction int) (that *Iterator)

func (*Iterator) Close

func (it *Iterator) Close()

func (*Iterator) Key

func (it *Iterator) Key() (ret Bytes)

func (*Iterator) Next

func (it *Iterator) Next() (ret bool)

func (*Iterator) Skip

func (it *Iterator) Skip(offset uint64) (ret bool)

func (*Iterator) Value

func (it *Iterator) Value() (ret Bytes)

type KIterator

type KIterator struct {
	*Iterator
}

func NewKIterator

func NewKIterator(it *Iterator) (ret *KIterator)

func (*KIterator) Next

func (kit *KIterator) Next() (ret bool)

type Options

type Options struct {
	Path        string
	CacheSize   int
	Compression bool
	ExpireDelay time.Duration
}

type QIterator

type QIterator struct {
	*Iterator
	// contains filtered or unexported fields
}

func NewQIterator

func NewQIterator(it *Iterator) (ret *QIterator)

func (*QIterator) Key

func (qit *QIterator) Key() (ret int64)

func (*QIterator) Next

func (qit *QIterator) Next() (ret bool)

type Status

type Status error

type Writer

type Writer struct {
	Mutex sync.Mutex
	// contains filtered or unexported fields
}

Writer for batch operations

func NewWriter

func NewWriter(db *leveldb.DB) *Writer

NewWriter return a leveldb batch writer

func (*Writer) Begin

func (w *Writer) Begin()

Begin before batch operation

func (*Writer) Commit

func (w *Writer) Commit() (err error)

Commit commit all operations

func (*Writer) Delete

func (w *Writer) Delete(key []byte)

Delete add a delete operation

func (*Writer) Do

func (w *Writer) Do()

Do try to do all operations

func (*Writer) Done

func (w *Writer) Done()

Done end the batch operations

func (*Writer) Put

func (w *Writer) Put(key []byte, val []byte)

Put add a set operation

func (*Writer) RollBack

func (w *Writer) RollBack()

RollBack rollback the batch operations

type XIterator

type XIterator struct {
	*Iterator
	// contains filtered or unexported fields
}

func NewXIterator

func NewXIterator(it *Iterator) (ret *XIterator)

func (*XIterator) Etime

func (xit *XIterator) Etime() (ret uint64)

func (*XIterator) Next

func (xit *XIterator) Next() (ret bool)

type ZIterator

type ZIterator struct {
	*Iterator
	// contains filtered or unexported fields
}

/***** ZSET *****/

func NewZIterator

func NewZIterator(it *Iterator) (ret *ZIterator)

func (*ZIterator) Key

func (zit *ZIterator) Key() (ret Bytes)

func (*ZIterator) Name

func (zit *ZIterator) Name() (ret Bytes)

func (*ZIterator) Next

func (zit *ZIterator) Next() (ret bool)

func (*ZIterator) Score

func (zit *ZIterator) Score() (ret int64)

func (*ZIterator) Value

func (zit *ZIterator) Value()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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