Documentation
¶
Index ¶
- Constants
- Variables
- type Bitcask
- func (b *Bitcask) BatchGet(keys []string) (map[string][]byte, error)
- func (b *Bitcask) BatchPut(pairs map[string][]byte) error
- func (b *Bitcask) Close() error
- func (b *Bitcask) Delete(key string) error
- func (b *Bitcask) Get(key string) ([]byte, error)
- func (b *Bitcask) Iterator() *Iterator
- func (b *Bitcask) Put(key string, value []byte) error
- func (b *Bitcask) Snapshot(snapshotDir string) error
- type ConfOption
- type Config
- type Iterator
- type MmapedFile
Constants ¶
const DefaultMaxDatafileSize = 1020 * 1024 * 10
DefaultMaxDatafileSize is the default maximum size of a datafile.
Variables ¶
var ( ErrKeyNotFound = errors.New("key not found") ErrIOFailure = errors.New("I/O operation failed") )
Functions ¶
This section is empty.
Types ¶
type Bitcask ¶
type Bitcask struct {
// contains filtered or unexported fields
}
func Open ¶
func Open(dir string, opts ...ConfOption) (*Bitcask, error)
Open opens a Bitcask database instance.
func (*Bitcask) Close ¶
Close closes the Bitcask database, ensuring all files are properly closed and memory maps are unmapped.
func (*Bitcask) Get ¶
Get retrieves the value associated with a given key from the Bitcask database.
func (*Bitcask) Iterator ¶
Iterator creates an iterator over the key-value pairs in the Bitcask database.
type ConfOption ¶
type ConfOption func(*Config)
func CompressData ¶
func CompressData(compress bool) ConfOption
CompressData sets whether to compress data.
func MaxDatafileSize ¶
func MaxDatafileSize(size int64) ConfOption
MaxDatafileSize sets the maximum size of a datafile.
func MergeInterval ¶
func MergeInterval(interval time.Duration) ConfOption
MergeInterval sets the interval for merging datafiles.
func MergeThreshold ¶
func MergeThreshold(threshold int) ConfOption
MergeThreshold sets the threshold for merging datafiles.
func SyncWrites ¶
func SyncWrites(sync bool) ConfOption
SyncWrites sets whether to sync writes to disk.
type Config ¶
type Config struct { MaxFileSize int64 MergeThreshold int SyncWrites bool CompressData bool MergeInterval time.Duration }
Config is the configuration for a Bitcask instance.
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
type MmapedFile ¶
type MmapedFile struct {
// contains filtered or unexported fields
}