storage

package module
v0.0.0-...-d5fbbed Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

storage

基于 bbolt 的 kv 数据库封装

Documentation

Overview

Package storage Date: 2024/3/26 11:20 Author: Amu Description:

Package storage Date: 2024/3/26 11:42 Author: Amu Description:

Index

Constants

This section is empty.

Variables

View Source
var (
	Separator = "/"

	ErrKeyNotFound = errors.New("Key is not found")
)

Functions

This section is empty.

Types

type Storage

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

func NewStorage

func NewStorage(path string) *Storage

func (*Storage) Delete

func (s *Storage) Delete(key string) error

Delete 删除 key

func (*Storage) Get

func (s *Storage) Get(key string) ([]byte, error)

func (*Storage) GetJson

func (s *Storage) GetJson(key string, out interface{}) error

func (*Storage) GetString

func (s *Storage) GetString(key string) (string, error)

func (*Storage) Keys

func (s *Storage) Keys(prefix string, recursive bool) ([]string, error)

func (*Storage) Path

func (s *Storage) Path() string

func (*Storage) Put

func (s *Storage) Put(key string, val []byte) error

func (*Storage) PutJson

func (s *Storage) PutJson(key string, val interface{}) error

func (*Storage) PutString

func (s *Storage) PutString(key string, val string) error

func (*Storage) Update

func (s *Storage) Update(fn func(tx *Tx) error) error

Update 写入操作

func (*Storage) View

func (s *Storage) View(fn func(tx *Tx) error) error

View 读取操作

type Tx

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

func (*Tx) Delete

func (tx *Tx) Delete(key string) error

func (*Tx) Get

func (tx *Tx) Get(key string) ([]byte, error)

func (*Tx) GetJson

func (tx *Tx) GetJson(key string, out interface{}) error

func (*Tx) GetString

func (tx *Tx) GetString(key string) (string, error)

func (*Tx) Keys

func (tx *Tx) Keys(prefix string, recursive bool) ([]string, error)

func (*Tx) Put

func (tx *Tx) Put(key string, val []byte) error

func (*Tx) PutJson

func (tx *Tx) PutJson(key string, val interface{}) error

func (*Tx) PutString

func (tx *Tx) PutString(key string, val string) error

Jump to

Keyboard shortcuts

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