storage

package
v0.0.0-...-31985c2 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decoder

func Decoder(data []byte, v interface{})

func Encoder

func Encoder(data interface{}) []byte

func Obj2Map

func Obj2Map(obj interface{}) map[string]interface{}

Types

type Item

type Item struct {
	Key   []byte
	Value []byte
	Index int64
	Score int64
}

type Items

type Items []Item

func (Items) Len

func (a Items) Len() int

func (Items) Less

func (a Items) Less(i, j int) bool

func (Items) Swap

func (a Items) Swap(i, j int)

type LeveldbStorage

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

LeveldbStorage TODO 要支持事务

func NewStorage

func NewStorage(path string, timeout int64) (*LeveldbStorage, error)

NewStorage 打开数据库

func (*LeveldbStorage) AutoId

func (s *LeveldbStorage) AutoId() int64

func (*LeveldbStorage) BatchSet

func (s *LeveldbStorage) BatchSet(kv *Items) ([]string, error)

func (*LeveldbStorage) Close

func (s *LeveldbStorage) Close() error

Close 关闭

func (*LeveldbStorage) DB

func (s *LeveldbStorage) DB() *leveldb.DB

func (*LeveldbStorage) Delete

func (s *LeveldbStorage) Delete(key []byte) error

Delete 删除

func (*LeveldbStorage) Get

func (s *LeveldbStorage) Get(key []byte) ([]byte, bool)

func (*LeveldbStorage) GetAll

func (s *LeveldbStorage) GetAll(start int64, end int64, order string, filter func(Item) (bool, Item)) (int64, Items)

func (*LeveldbStorage) GetCount

func (s *LeveldbStorage) GetCount() int64

func (*LeveldbStorage) GetList

func (s *LeveldbStorage) GetList(start int64, end int64, order string, filter func(Item) (bool, Item), is_sanp bool) (int64, Items)

func (*LeveldbStorage) Has

func (s *LeveldbStorage) Has(key []byte) bool

func (*LeveldbStorage) NewItem

func (s *LeveldbStorage) NewItem(key []byte, value []byte) *Item

func (*LeveldbStorage) ReOpen

func (s *LeveldbStorage) ReOpen() error

func (*LeveldbStorage) Search

func (s *LeveldbStorage) Search(callback func(Item) (v any), option *SearchOption) (int64, Items)

callbacl传入要转换的对你

func (*LeveldbStorage) Set

func (s *LeveldbStorage) Set(key []byte, value []byte) error

type SearchOption

type SearchOption struct {
	FilterExp string
	ScoreExp  string
	Start     int64
	End       int64
	Order     string
}

Jump to

Keyboard shortcuts

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