blt

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AssetBucketName      = "Asset"
	PathBucketName       = "Path"
	TagBucketName        = "Tag"
	TagHistoryBucketName = "TagHistory"
	MetaBucketName       = "Meta"
)

Variables

This section is empty.

Functions

func Btoi

func Btoi(bytes []byte) uint64

func CreateAssetBucketNames

func CreateAssetBucketNames(ws model.WSName) []string

func CreateMetaBucketNames

func CreateMetaBucketNames() []string

func CreatePathBucketNames

func CreatePathBucketNames(ws model.WSName) []string

func CreateTagBucketNames

func CreateTagBucketNames(ws model.WSName) []string

func CreateTagHistoryBucketNames

func CreateTagHistoryBucketNames(ws model.WSName) []string

func Itob

func Itob(v uint64) []byte

Types

type BoltData

type BoltData interface {
	GetID() uint64
	SetID(id uint64)
}

type Repository

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

func NewRepository

func NewRepository(b *bolt.DB) *Repository

func (*Repository) Add

func (b *Repository) Add(bucketNames []string, data interface{}) (uint64, error)

add adds data to bolt and set new ID which generated by bolt to data. So this method modifies data argument. This method always assign new ID to data, so even if already data have ID other than 0, it will be ignored and overwritten.

func (*Repository) AddIntByString

func (b *Repository) AddIntByString(bucketNames []string, k string, v uint64) error

func (*Repository) AddWithID

func (b *Repository) AddWithID(bucketNames []string, data BoltData) (uint64, error)

addWithID adds data to bolt and set new ID which generated by bolt to data. So this method modifies data argument. This method always assign new ID to data, so even if already data have ID other than 0, it will be ignored and overwritten.

func (*Repository) BatchAddIntByString

func (b *Repository) BatchAddIntByString(bucketNames []string, keys []string, values []uint64) error

func (*Repository) BatchAddWithID

func (b *Repository) BatchAddWithID(bucketNames []string, dataList []BoltData) (idList []uint64, err error)

func (*Repository) BatchGet

func (b *Repository) BatchGet(bucketNames []string, idList []uint64) (dataList [][]byte, err error)

func (*Repository) BatchGetByString

func (b *Repository) BatchGetByString(bucketNames []string, keys []string) (dataList [][]byte, err error)

func (*Repository) BatchUpdateByID

func (b *Repository) BatchUpdateByID(bucketNames []string, dataList []BoltData) (updatedDataList []BoltData, skippedDataList []BoltData, err error)

BatchUpdateByID update data by ID. If ID does not exist in bucket, skip the data.

func (*Repository) BucketFunc

func (b *Repository) BucketFunc(bucketNames []string, f func(bucket *bolt.Bucket) error) error

func (*Repository) Close

func (b *Repository) Close() error

func (*Repository) CreateBucketIfNotExist

func (b *Repository) CreateBucketIfNotExist(bucketNames []string) error

func (*Repository) Delete

func (b *Repository) Delete(bucketNames []string, id uint64) error

func (*Repository) ForEach

func (b *Repository) ForEach(bucketNames []string, f func(value []byte) error) error

func (*Repository) Get

func (b *Repository) Get(bucketNames []string, id uint64) (data []byte, exist bool, err error)

func (*Repository) GetIDByString

func (b *Repository) GetIDByString(bucketNames []string, key string) (id uint64, exist bool, err error)

func (*Repository) List

func (b *Repository) List(bucketNames []string) (dataList [][]byte, err error)

func (*Repository) LoBucketFunc

func (b *Repository) LoBucketFunc(bucketNames []string, f func(bucket *bolt.Bucket) error) error

func (*Repository) RecreateBucket

func (b *Repository) RecreateBucket(bucketNames []string) error

func (*Repository) SaveByID

func (b *Repository) SaveByID(bucketNames []string, data BoltData) (retID uint64, err error)

SaveByID add or update data. If data ID does not provided, add new data. If data ID provided, update data which have the ID. If data ID provided, but data which have the ID does not exist, return error.

func (*Repository) UpdateByID

func (b *Repository) UpdateByID(bucketNames []string, data BoltData) error

UpdateByID updates data by ID. if data which have ID does not exist, return error.

Jump to

Keyboard shortcuts

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