Documentation ¶
Overview ¶
Package bitbutt implements a key-value store based on Basho's bitcask log-structured hash-table.
Index ¶
- Constants
- type BitButt
- func (b *BitButt) AllKeys() (<-chan []byte, error)
- func (b *BitButt) Begin() *Tx
- func (b *BitButt) Close()
- func (b *BitButt) Delete(key []byte) error
- func (b *BitButt) Get(key []byte) ([]byte, error)
- func (b *BitButt) Merge() error
- func (b *BitButt) Put(key []byte, value []byte) error
- func (b *BitButt) Sync() error
- type MergeWindow
- type Option
- type Tx
Constants ¶
const ( // KiB is to be used with ThresholdSize to specify kibibytes (1024 bytes). KiB uint64 = 1024 // MiB is to be used with ThresholdSize to specify mibibytes (1024 kibibytes). MiB = 1024 * KiB // GiB is to be used with ThresholdSize to specify gibibytes (1024 mibibytes). GiB = 1024 * MiB // DefaultSize is the default threshold size. DefaultSize = 2 * GiB )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BitButt ¶
type BitButt struct {
// contains filtered or unexported fields
}
BitButt implements a key-value store based on Basho's bitcask log-structured hash-table.
func Open ¶
Open opens a bitbutt key-value store, found in directory. If directory doesn't exist yet, it is created. It returns a BitButt object, or an error if opening and loading the key-value store failed.
func (*BitButt) AllKeys ¶
AllKeys returns a channel from which all keys within the bitbutt can be received. It returns an error if there was a problem retrieving the keys.
func (*BitButt) Close ¶
func (b *BitButt) Close()
Close creates missing hint files, closes all open data files, and invalidates the BitButt object.
func (*BitButt) Delete ¶
Delete deletes the record identified by key. If the delete operation fails, it returns an error.
func (*BitButt) Get ¶
Get returns the stored value for the specified key, or an error if the key-value pair doesn't exist or there was another error when retrieving the value.
func (*BitButt) Merge ¶
Merge merges existing data files if more than one (in addition to the currently active file) exist.
type MergeWindow ¶
MergeWindow specifies the time window when automatic merges will be conducted.
var ( // Never is the default MergeWindow: never merge automatically Never *MergeWindow // Always is the merge window to always merge automatically Always = &MergeWindow{0, 23} )
type Option ¶
type Option func(*BitButt)
Option is a data type to set options when calling Open.
func AllowedMergeWindow ¶
func AllowedMergeWindow(window *MergeWindow) Option
AllowedMergeWindow sets a merge window. If a merge window other than Never is set, merges will be conducted regularly and automatically within that timeframe.
func SizeThreshold ¶
SizeThreshold sets the size threshold when a bitbutt store shall create a new data file.
func SyncInterval ¶
SyncInterval makes a bitbutt store repeatedy call fsync(2) at a specified interval.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx is a transaction.
A transaction must always be ended with a call to either Commit or Rollback. After a Commit or Rollback, all operations on the transaction return an error.
func (*Tx) Commit ¶
Commit commits the transaction. It returns an error if there is an update conflict (i.e. at least one of the keys updated in the current transaction has been updated since the start of the transaction) or if the write to the bitbutt data file fails.
func (*Tx) Delete ¶
Delete marks the record identified by key for deletion. It takes key-value pairs that were set or updated in the current transaction into account.
func (*Tx) Get ¶
Get returns the stored value of the specified key. It takes key-value pairs that were updated in the current transaction into account.