RocksDBStore

package
v0.0.0-...-67b0b38 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STRING    ElementType = 's'
	HASH                  = 'h'
	LIST                  = 'l'
	SORTEDSET             = 'z'
	NONE                  = '0'
)
View Source
const (
	MINBYTE byte = 0
	MAXBYTE byte = math.MaxUint8
)

字节范围

Variables

View Source
var (
	SEP = []byte{','}
	KEY = []byte{'+'} // Key Prefix
	SOK = []byte{'['} // Start of Key
	EOK = []byte{']'} // End of Key
)
View Source
var KEY_EXIST = []byte("1")
View Source
var KEY_NOT_EXIST = []byte("0")

Functions

func Bytes2str

func Bytes2str(b []byte) string

func BytesToInt64

func BytesToInt64(buf []byte) int64

func IncrSignal

func IncrSignal(val int64) int64

func Int64ToBytes

func Int64ToBytes(i int64) []byte

使用二进制存储整形

func NewRocksDB

func NewRocksDB(dir string) *gorocksdb.DB

func SplitKeyName

func SplitKeyName(key []byte) (string, string)

func Str2bytes

func Str2bytes(s string) []byte

Types

type Counter

type Counter int64

Atomic Counter, simple enough, easy to Incr/Decr c := Counter(0) c.SetCount(100) c.Incr(1) or c.Decr(1) fmt.Println(c) or c.Count()

func (*Counter) Count

func (c *Counter) Count() int64

func (*Counter) Decr

func (c *Counter) Decr(delta int64) int64

func (*Counter) Incr

func (c *Counter) Incr(delta int64) int64

func (*Counter) SetCount

func (c *Counter) SetCount(val int64)

func (*Counter) String

func (c *Counter) String() string

type Counters

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

Counter Collection factory := NewFactory() factory.Get("set").Incr(1) factory.Get("get").Incr(1) factory.Get("del").Incr(1) factory.Get("total").Incr(3)

func NewCounters

func NewCounters() *Counters

func (*Counters) C

func (f *Counters) C(name string) *Counter

Get or auto create a Counter by name

type DB

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

func New

func New(rdb *gorocksdb.DB) *DB

func (*DB) Close

func (d *DB) Close()

func (*DB) Delete

func (d *DB) Delete(key []byte) error

func (*DB) Enumerate

func (d *DB) Enumerate(iter *gorocksdb.Iterator, min, max []byte, direction IterDirection, fn func(i int, key, value []byte, quit *bool))

范围扫描

func (*DB) FLushAll

func (d *DB) FLushAll()

func (*DB) Get

func (d *DB) Get(key []byte) ([]byte, error)

func (*DB) GetList

func (d *DB) GetList(key []byte) ([]byte, error)

func (*DB) Keys

func (d *DB) Keys() []string

func (*DB) List

func (d *DB) List(key []byte) *ListElement

func (*DB) PrefixEnumerate

func (d *DB) PrefixEnumerate(prefix []byte, direction IterDirection, fn func(i int, key, value []byte, quit *bool))

前缀扫描

func (*DB) RangeEnumerate

func (d *DB) RangeEnumerate(min, max []byte, direction IterDirection, fn func(i int, key, value []byte, quit *bool))

func (*DB) RawDelete

func (d *DB) RawDelete(key []byte) error

func (*DB) RawGet

func (d *DB) RawGet(key []byte) ([]byte, error)

func (*DB) RawSet

func (d *DB) RawSet(key, value []byte) error

func (*DB) Set

func (d *DB) Set(key, value []byte) error

func (*DB) TypeOf

func (d *DB) TypeOf(key []byte) ElementType

func (*DB) WriteBatch

func (d *DB) WriteBatch(batch *gorocksdb.WriteBatch) error

type ElementType

type ElementType byte

func (ElementType) String

func (e ElementType) String() string

type IterDirection

type IterDirection int
const (
	IterForward IterDirection = iota
	IterBackward
)

type Iterator

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

func (*Iterator) First

func (it *Iterator) First() bool

func (*Iterator) Key

func (it *Iterator) Key() []byte

func (*Iterator) Last

func (it *Iterator) Last() bool

func (*Iterator) Next

func (it *Iterator) Next() bool

func (*Iterator) Prev

func (it *Iterator) Prev() bool

func (*Iterator) Release

func (it *Iterator) Release()

func (*Iterator) Seek

func (it *Iterator) Seek(key []byte) bool

func (*Iterator) Value

func (it *Iterator) Value() []byte

type ListElement

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

func NewHashElement

func NewHashElement(db *DB, key []byte) *ListElement

func NewListElement

func NewListElement(db *DB, key []byte) *ListElement

func NewSortedSetElement

func NewSortedSetElement(db *DB, key []byte) *ListElement

func (*ListElement) Drop

func (l *ListElement) Drop() error

func (*ListElement) Exist

func (l *ListElement) Exist() (bool, error)

move out side

func (*ListElement) Index

func (l *ListElement) Index(i int64) ([]byte, error)

func (*ListElement) LPop

func (l *ListElement) LPop() ([]byte, error)

func (*ListElement) LPush

func (l *ListElement) LPush(vals ...[]byte) error

func (*ListElement) Len

func (l *ListElement) Len() int64

func (*ListElement) Ltrim

func (l *ListElement) Ltrim(start, stop int) error

func (*ListElement) RPop

func (l *ListElement) RPop() ([]byte, error)

func (*ListElement) RPush

func (l *ListElement) RPush(vals ...[]byte) error

func (*ListElement) Range

func (l *ListElement) Range(start, stop int, fn func(i int, value []byte, quit *bool)) error

Jump to

Keyboard shortcuts

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