localpersistence

package
v1.9.5 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2020 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultDecoder = func(b []byte, value interface{}) error {
	return jsoniter.Unmarshal(b, value)
}
View Source
var DefaultEncoder = func(value interface{}) ([]byte, error) {
	return jsoniter.Marshal(value)
}

Functions

This section is empty.

Types

type DB

type DB = leveldb.DB

type DBOptions

type DBOptions = opt.Options

type DecoderFunc

type DecoderFunc func([]byte, interface{}) error

type EncoderFunc

type EncoderFunc func(value interface{}) ([]byte, error)

type List

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

func OpenList

func OpenList(file string, opts *Options) (*List, error)

打开数据库

func (*List) AddToFirst

func (l *List) AddToFirst(value interface{}) error

添加到队列首

func (*List) AddToLast

func (l *List) AddToLast(value interface{}) error

添加到队列尾

func (*List) Close

func (l *List) Close() error

关闭数据库

func (*List) RemoveFirst

func (l *List) RemoveFirst(value interface{}) (ok bool, err error)

删除队列首

func (*List) RemoveLast

func (l *List) RemoveLast(value interface{}) (ok bool, err error)

删除队列尾

func (*List) Size

func (l *List) Size() (size int, err error)

队列元素数量

type Map

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

func OpenMap

func OpenMap(file string, opts *Options) (*Map, error)

打开数据库

func (*Map) Close

func (m *Map) Close() error

关闭数据库

func (*Map) ForEachKey

func (m *Map) ForEachKey(fn func(key string) bool) (err error)

遍历所有key

func (*Map) Get

func (m *Map) Get(key string, value interface{}) (ok bool, err error)

获取元素值

func (*Map) Put

func (m *Map) Put(key string, value interface{}) (err error)

设置元素值

func (*Map) Remove

func (m *Map) Remove(key string) (err error)

设置元素值

func (*Map) Size

func (m *Map) Size() (size int, err error)

元素数量

type Options

type Options struct {
	DB      *DBOptions
	Encoder EncoderFunc
	Decoder DecoderFunc
}

type SortedList

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

func OpenSortedList

func OpenSortedList(file string, opts *SortedListOptions) (*SortedList, error)

打开数据库

func (*SortedList) Add

func (l *SortedList) Add(score int64, value interface{}) error

func (*SortedList) Close

func (l *SortedList) Close() error

关闭数据库

func (*SortedList) First

func (l *SortedList) First(maxScore int64, value interface{}) (score int64, ok bool, err error)

取得第一个元素

func (*SortedList) Size

func (l *SortedList) Size() (size int, err error)

队列元素数量

type SortedListOptions added in v1.6.2

type SortedListOptions struct {
	*Options
	IteratorMaxMilliseconds int64 // 迭代器缓存时间
}

Jump to

Keyboard shortcuts

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