storage

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StartAt = 123456
)

Variables

View Source
var (
	ErrBucketNotFound = bolt.ErrBucketNotFound
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// Path is the file path to the storage file.
	Path string
	// BatchInterval is the maximum time before flushing the BatchTx.
	// 提交两次批量事务的最大时间差,默认 100ms
	BatchInterval time.Duration
	// BatchLimit is the maximum puts before flushing the BatchTx.
	// 指定每个批量读写事务能包含的最多操作个数,当超过这个阈值后,当前批量读写事务会自动提交
	BatchLimit int
	MmapSize   int
}

func DefaultConfig

func DefaultConfig() *Config

type Storage

type Storage interface {
	// Methods to manage key/value pairs
	// Read-Only transactions
	View(bucket, key []byte) ([]byte, error)
	// Create or update a key
	// The caller should make sure the key exists when update a key
	Update(bucket, key, value []byte) error
	// Delete a key from bucket
	Delete(bucket, key []byte) error
	// Generate a index for the url and store it
	Index(value []byte) (uint64, error)

	// Methods to manage a Bucket
	CreateBucket(bucket []byte) error
	DeleteBucket(bucket []byte) error
}

func New

func New(c *Config) Storage

Jump to

Keyboard shortcuts

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