kvdb

package
v0.0.0-...-afa1935 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

func (*DB) Del

func (dbase *DB) Del(key string) error

func (*DB) Expire

func (dbase *DB) Expire(key string, ttl time.Duration) error

func (*DB) Get

func (dbase *DB) Get(key string) (string, error)

func (*DB) GetBytes

func (dbase *DB) GetBytes(key string) ([]byte, error)

func (*DB) Range

func (dbase *DB) Range() ([]*KV, error)

func (*DB) Set

func (dbase *DB) Set(key, val string, ttl time.Duration) error

func (*DB) SetBytes

func (dbase *DB) SetBytes(key string, val []byte, ttl time.Duration) error

func (*DB) TTL

func (dbase *DB) TTL(key string) (time.Duration, error)

type DBType

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

DBType BlotDB的管理类

func (*DBType) Backup

func (dbase *DBType) Backup(backupDbFilePath string) error

Backup 备份数据库文件

func (*DBType) Close

func (dbase *DBType) Close()

Close 关库数据库

func (*DBType) DeleteBucket

func (dbase *DBType) DeleteBucket(bucketName string) error

DeleteBucket 删除Bucket

func (*DBType) DeleteByKeys

func (dbase *DBType) DeleteByKeys(keys []string) error

DeleteByKeys 删除键值

func (*DBType) DeleteByKeysTransaction

func (dbase *DBType) DeleteByKeysTransaction(keys []string) error

DeleteByKeysTransaction 在事务中,删除键值

func (*DBType) GetAll

func (dbase *DBType) GetAll() (map[string][]byte, error)

GetAll 获取全部

func (*DBType) GetByKey

func (dbase *DBType) GetByKey(key string) ([]byte, error)

GetByKey 根据键名获取各自的值, key 键名

func (*DBType) GetByKeys

func (dbase *DBType) GetByKeys(keys []string) (map[string][]byte, error)

GetByKeys 根据键名数组获取各自的值, keys 键名数组

func (*DBType) Set

func (dbase *DBType) Set(kv map[string][]byte) error

Set 设置值 kv 键值对

type KV

type KV struct {
	// Key
	Key string
	// Value
	Val string
	// TTL(存活时间), 如果设置 ttl = 0 or Persistent, 这个key就会永久不删除
	TTL time.Duration
}

type KVInterface

type KVInterface interface {
	// Set 设置值 kv 键值对
	Set(kv map[string][]byte) error
	// GetByKey 根据键名获取各自的值, key 键名
	GetByKey(key string) ([]byte, error)
	// GetByKeys 根据键名数组获取各自的值, keys 键名数组
	GetByKeys(keys []string) (map[string][]byte, error)
	// GetAll 获取全部
	GetAll() (map[string][]byte, error)
	// DeleteByKeys 删除键值
	DeleteByKeys(keys []string) error
	// DeleteByKeysTransaction 在事务中,删除键值
	DeleteByKeysTransaction(keys []string) error
	// DeleteBucket 移除Bucket
	DeleteBucket(bucketName string) (err error)
	// Backup 备份数据库文件
	Backup(backupDbFilePath string) error
	// Close 关库数据库
	Close()
}

func NewKvDb

func NewKvDb(dbFilePath string, bucketName string) KVInterface

NewKvDb 初始化实例

type KeyValueStore

type KeyValueStore interface {
	GetBytes(key string) ([]byte, error)
	Get(key string) (string, error)
	SetBytes(key string, val []byte, ttl time.Duration) error
	Set(key, val string, ttl time.Duration) error
	TTL(key string) (time.Duration, error)
	Expire(key string, ttl time.Duration) error
	Del(key string) error
	Range() ([]*KV, error)
}

func NewDB

func NewDB(filepath string) KeyValueStore

Jump to

Keyboard shortcuts

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