Documentation ¶
Index ¶
- type CycleDB
- func (c *CycleDB) AsyncWrite(ctx context.Context, towrite []KvPair)
- func (c *CycleDB) Close() error
- func (c *CycleDB) CycleNodes() error
- func (c *CycleDB) DB() *bolt.DB
- func (c *CycleDB) Delete(keys [][]byte) ([]bool, error)
- func (c *CycleDB) Read(toread [][]byte) ([][]byte, error)
- func (c *CycleDB) Stats() Stats
- func (c *CycleDB) VerifyBuckets() error
- func (c *CycleDB) VerifyCompressed() error
- func (c *CycleDB) Write(towrite []KvPair) error
- type DBConfiguration
- type KvPair
- type Stats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CycleDB ¶
type CycleDB struct {
// contains filtered or unexported fields
}
CycleDB allows you to use a bolt.DB as a pseudo-LRU using a cycle of buckets
func New ¶
func New(db *bolt.DB, optionalParameters ...DBConfiguration) (*CycleDB, error)
New creates a CycleDB to use a bolt database that cycles minNumOldBuckets buckets
func (*CycleDB) AsyncWrite ¶
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 (*CycleDB) Close ¶
Close ends the goroutine that moves read items to the latest bucket and now closes the DB itself...
func (*CycleDB) CycleNodes ¶
CycleNodes deletes the first, oldest node in the primary bucket while there are >= minNumOldBuckets and creates a new, empty last node
func (*CycleDB) Delete ¶
Delete all the keys from every bucket that could have the keys. Returns true/false for each key if it exists
func (*CycleDB) Read ¶
Read bytes from the first available bucket. Do not modify the returned bytes because they are recopied to later cycle databases if needed.
func (*CycleDB) Stats ¶
Stats returns introspection stats about the Database. The members are considered alpha and subject to change or rename.
func (*CycleDB) VerifyBuckets ¶
VerifyBuckets ensures that the cycle of buckets have the correct names (increasing 8 byte integers)
func (*CycleDB) VerifyCompressed ¶
VerifyCompressed checks that no key is repeated in the database
type DBConfiguration ¶
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 ReadMovementBacklog ¶
func ReadMovementBacklog(readMovementBacklog int) DBConfiguration
ReadMovementBacklog sets the size of the channel of read operations to rewrite
type Stats ¶
type Stats struct { TotalItemsRecopied int64 TotalItemsAsyncPut int64 RecopyTransactionCount int64 TotalItemsDeletedDuringRecopy int64 TotalReadCount int64 TotalWriteCount int64 TotalDeleteCount int64 TotalCycleCount int64 TotalErrorsDuringRecopy int64 TotalReadMovementsSkipped int64 TotalReadMovementsAdded int64 SizeOfBacklogToCopy int }
Stats are exported by CycleDB to let users inspect its behavior over time
func (*Stats) AtomicClone ¶ added in v1.1.0
AtomicClone creates a new stats with somewhat atomically