Documentation ¶
Index ¶
- Constants
- func ErrNotFound(err error) bool
- func Register(name string, f NewStorageFunc)
- type Batch
- type Database
- type Iterator
- type KVParameter
- func (param *KVParameter) GetDBPath() string
- func (param *KVParameter) GetFileHandlersCacheSize() int
- func (param *KVParameter) GetKVEngineType() string
- func (param *KVParameter) GetMemCacheSize() int
- func (param *KVParameter) GetOtherPaths() []string
- func (param *KVParameter) GetStorageType() string
- type NewStorageFunc
- type QuickIterator
Constants ¶
const ( KVEngineTypeLDB = "leveldb" KVEngineTypeBadger = "badger" )
const ( StorageTypeSingle = "single" StorageTypeMulti = "multi" StorageTypeCloud = "cloud" )
Variables ¶
This section is empty.
Functions ¶
func ErrNotFound ¶
ErrNotFound return true or false when key not found
func Register ¶
func Register(name string, f NewStorageFunc)
Types ¶
type Batch ¶
type Batch interface { ValueSize() int Write() error Reset() Put(key []byte, value []byte) error Delete(key []byte) error PutIfAbsent(key []byte, value []byte) error Exist(key []byte) bool }
Batch Batch操作的接口
type Database ¶
type Database interface { Open(path string, options map[string]interface{}) error Put(key []byte, value []byte) error Get(key []byte) ([]byte, error) Has(key []byte) (bool, error) Delete(key []byte) error Close() NewBatch() Batch NewIteratorWithRange(start []byte, limit []byte) Iterator NewIteratorWithPrefix(prefix []byte) Iterator }
Database KV数据库的接口
func CreateKVInstance ¶
func CreateKVInstance(kvParam *KVParameter) (Database, error)
type Iterator ¶
type Iterator interface { Key() []byte Value() []byte Next() bool Prev() bool Last() bool First() bool Error() error Release() }
Iterator NewIteratorXX操作后得到的迭代器
type KVParameter ¶
type KVParameter struct { DBPath string KVEngineType string StorageType string MemCacheSize int FileHandlersCacheSize int OtherPaths []string Options map[string]interface{} }
KVParameter structure for kv instance parameters
func (*KVParameter) GetDBPath ¶
func (param *KVParameter) GetDBPath() string
GetDBPath return the value of DBPath
func (*KVParameter) GetFileHandlersCacheSize ¶
func (param *KVParameter) GetFileHandlersCacheSize() int
GetFileHandlersCacheSize return the value of FileHandlersCacheSize
func (*KVParameter) GetKVEngineType ¶
func (param *KVParameter) GetKVEngineType() string
GetKVEngineType return the value of KVEngineType
func (*KVParameter) GetMemCacheSize ¶
func (param *KVParameter) GetMemCacheSize() int
GetMemCacheSize return the value of MemCacheSize
func (*KVParameter) GetOtherPaths ¶
func (param *KVParameter) GetOtherPaths() []string
GetOtherPaths return the value of OtherPaths
func (*KVParameter) GetStorageType ¶
func (param *KVParameter) GetStorageType() string
GetStorageType return the value of GetStorageType
type NewStorageFunc ¶
type NewStorageFunc func(*KVParameter) (Database, error)
type QuickIterator ¶
type QuickIterator struct {
// contains filtered or unexported fields
}
QuickIterator define the data structure of quick iterator
func NewQuickIterator ¶
func NewQuickIterator(ldb Database, prefix []byte, middleKey []byte) *QuickIterator
NewQuickIterator new quick iterator instance
func (*QuickIterator) Error ¶
func (qi *QuickIterator) Error() error
Error return err for quick iterator
func (*QuickIterator) Release ¶
func (qi *QuickIterator) Release()
Release release iterators of quick iterator
func (*QuickIterator) Value ¶
func (qi *QuickIterator) Value() []byte
Value get value by quick iterator