pdbcycle

package
Version: v2.5.2-0...-f3a5e34 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CyclePDB

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

CyclePDB allows you to use a bolt.DB as a pseudo-LRU using a cycle of buckets

func New

func New(dataDir string, optionalParameters ...DBConfiguration) (ret *CyclePDB, err error)

New creates a CyclePDB to use a bolt database that cycles minNumOldBuckets buckets

func (*CyclePDB) AsyncWrite

func (c *CyclePDB) AsyncWrite(ctx context.Context, towrite []boltcycle.KvPair)

AsyncWrite will enqueue a write into the same chan that moves reads to the last bucket. You must not *ever* change the []byte given to towrite since you can't know when that []byte is finished being used. Note that if the readMovements queue is backed up this operation will block until it has room.

func (*CyclePDB) Close

func (c *CyclePDB) Close() error

Close ends the goroutine that moves read items to the latest bucket

func (*CyclePDB) CycleNodes

func (c *CyclePDB) CycleNodes() error

CycleNodes deletes the first, oldest node in the primary bucket while there are >= minNumOldBuckets and creates a new, empty last node

func (*CyclePDB) DB

func (c *CyclePDB) DB() *bolt.DB

DB exposes raw bolt db

func (*CyclePDB) Delete

func (c *CyclePDB) Delete(keys [][]byte) ([]bool, error)

Delete all the keys from every bucket that could have the keys. Returns true/false for each key if it exists

func (*CyclePDB) Read

func (c *CyclePDB) Read(toread [][]byte) ([][]byte, error)

Read bytes from the first available bucket. Do not modify the returned bytes because they are recopied to later cycle databases if needed.

func (*CyclePDB) Stats

func (c *CyclePDB) Stats() boltcycle.Stats

Stats returns introspection stats about the Database. The members are considered alpha and subject to change or rename.

func (*CyclePDB) VerifyBuckets

func (c *CyclePDB) VerifyBuckets() error

VerifyBuckets ensures that the cycle of buckets have the correct names

func (*CyclePDB) Write

func (c *CyclePDB) Write(towrite []boltcycle.KvPair) (err error)

Write a pair of key/value items into the cycle disk

type DBConfiguration

type DBConfiguration func(*CyclePDB) error

DBConfiguration are callbacks used as optional vardic parameters in New() to configure DB usage

func AsyncErrors

func AsyncErrors(asyncErrors chan<- error) DBConfiguration

AsyncErrors controls where we log async errors into. If nil, they are silently dropped

func BucketTimesIn

func BucketTimesIn(bucketName []byte) DBConfiguration

BucketTimesIn is the sub bucket we put our cycled hashmap into

func CycleLen

func CycleLen(minNumOldBuckets int) DBConfiguration

CycleLen sets the number of old buckets to keep around

func DiskTimeOut

func DiskTimeOut(timeOut time.Duration) DBConfiguration

DiskTimeOut configures how logn we wait to get a lock within boltdb

func InitDB

func InitDB(b bool) DBConfiguration

InitDB initializes a new db

func MaxBatchSize

func MaxBatchSize(size int) DBConfiguration

MaxBatchSize configures how logn we wait to get a lock within boltdb

func MetaBucketName

func MetaBucketName(bucketName []byte) DBConfiguration

MetaBucketName is the sub bucket we put our metadata

func ReadMovementBacklog

func ReadMovementBacklog(readMovementBacklog int) DBConfiguration

ReadMovementBacklog sets the size of the channel of read operations to rewrite

Source Files

Jump to

Keyboard shortcuts

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