badger

package
v0.0.0-...-15a51b0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

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

func CreateBucket

func CreateBucket(name string, stor *Store) *Bucket

func (*Bucket) BatchDelete

func (s *Bucket) BatchDelete(keys [][]byte) error

BatchDelete

func (*Bucket) BatchGet

func (s *Bucket) BatchGet(keys [][]byte) ([][]byte, error)

BatchGet 返回的values与传入的keys顺序保持一致。如果key不存在或读取失败则对应的value是空数组

func (*Bucket) BatchSet

func (s *Bucket) BatchSet(keys, values [][]byte) error

BatchSet 多个写操作使用一个事务

func (*Bucket) BatchSetWithTTL

func (s *Bucket) BatchSetWithTTL(keys, values [][]byte, expireAts []int64) error

BatchSet 多个写操作使用一个事务

func (*Bucket) Chan

func (s *Bucket) Chan(ch chan<- interface{}) int64

func (*Bucket) Delete

func (s *Bucket) Delete(k []byte) error

Delete

func (*Bucket) Get

func (s *Bucket) Get(k []byte) ([]byte, error)

Get 如果key不存在会返回error:Key not found

func (*Bucket) Has

func (s *Bucket) Has(k []byte) bool

Has 判断某个key是否存在

func (*Bucket) Iter

func (s *Bucket) Iter(fn func(k, v []byte) error) int64

IterDB 遍历整个DB

func (*Bucket) IterKeys

func (s *Bucket) IterKeys(fn func(k []byte) error) int64

IterKey 只遍历key。key是全部存在LSM tree上的,只需要读内存,所以很快

func (*Bucket) Set

func (s *Bucket) Set(k, v []byte) error

func (*Bucket) SetWithTTL

func (s *Bucket) SetWithTTL(k, v []byte, expireAt int64) error

func (*Bucket) Stream

func (s *Bucket) Stream(fn func(k []byte, v []byte) error) int64

type Logger

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

func NewLogger

func NewLogger(logger *zap.Logger) *Logger

func (*Logger) Debugf

func (l *Logger) Debugf(template string, args ...interface{})

func (*Logger) Errorf

func (l *Logger) Errorf(template string, args ...interface{})

func (*Logger) Infof

func (l *Logger) Infof(template string, args ...interface{})

func (*Logger) Warningf

func (l *Logger) Warningf(template string, args ...interface{})

type Store

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

Store is a wrapper around a badger DB

func Open

func Open(dbPath string, logger *zap.Logger) (*Store, error)

func (*Store) BatchDelete

func (s *Store) BatchDelete(keys [][]byte) error

BatchDelete

func (*Store) BatchGet

func (s *Store) BatchGet(keys [][]byte) ([][]byte, error)

BatchGet 返回的values与传入的keys顺序保持一致。如果key不存在或读取失败则对应的value是空数组

func (*Store) BatchSet

func (s *Store) BatchSet(keys, values [][]byte) error

BatchSet 多个写操作使用一个事务

func (*Store) BatchSetWithTTL

func (s *Store) BatchSetWithTTL(keys, values [][]byte, expireAts []int64) error

BatchSet 多个写操作使用一个事务

func (*Store) CheckAndGC

func (s *Store) CheckAndGC()

func (*Store) Clean

func (s *Store) Clean() error

Clean 清空所有数据

func (*Store) Close

func (s *Store) Close() error

Close 把内存中的数据flush到磁盘,同时释放文件锁

func (*Store) CreateBucket

func (s *Store) CreateBucket(name string) *Bucket

func (*Store) Delete

func (s *Store) Delete(k []byte) error

Delete

func (*Store) Get

func (s *Store) Get(k []byte) ([]byte, error)

Get 如果key不存在会返回error:Key not found

func (*Store) Has

func (s *Store) Has(k []byte) bool

Has 判断某个key是否存在

func (*Store) Iter

func (s *Store) Iter(fn func(k, v []byte) error) int64

IterDB 遍历整个DB

func (*Store) IterByPrefix

func (s *Store) IterByPrefix(prefix string, fn func(k, v []byte) error) int64

func (*Store) IterKeys

func (s *Store) IterKeys(fn func(k []byte) error) int64

IterKey 只遍历key。key是全部存在LSM tree上的,只需要读内存,所以很快

func (*Store) IterKeysByPrefix

func (s *Store) IterKeysByPrefix(prefix string, fn func(k []byte) error) int64

func (*Store) Set

func (s *Store) Set(k, v []byte) error

func (*Store) SetWithTTL

func (s *Store) SetWithTTL(k, v []byte, expireAt int64) error

func (*Store) Size

func (s *Store) Size() (int64, int64)

Jump to

Keyboard shortcuts

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