| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
This package is not in the latest version of its module.
Go to latest Published: May 12, 2023 License: MITThe Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Modules with tagged versions give importers more predictable builds.
When a project reaches major version v1 it is considered stable.
const ( // DefaultDirFileModeBeforeUmask is the default os.FileMode used when creating directories DefaultDirFileModeBeforeUmask = os.FileMode(0700) // DefaultFileFileModeBeforeUmask is the default os.FileMode used when creating files DefaultFileFileModeBeforeUmask = os.FileMode(0600) // DefaultMaxDatafileSize is the default maximum datafile size in bytes DefaultMaxDatafileSize = 100 * 1024 * 1024 // 100MB // Data size exceeding this threshold to temporarily copied to TempDir DefaultCopyTempThrshold int64 = 10 * 1024 * 1024 // DefaultSync is the default file synchronization action DefaultSync = false DefaultNoRepliEmit bool = true DefaultRepliBindIP string = "[0.0.0.0]" DefaultRepliBindPort int = 4220 DefaultNoRepliRecv bool = true DefaultRepliServerIP string = "127.0.0.1" DefaultRepliServerPort int = 4220 DefaultRepliRequestTimeout time.Duration = 10 * time.Second )
const ( AppName string = "bitcaskdb" Version string = "1.6.1" )
var ( // ErrKeyNotFound is the error returned when a key is not found ErrKeyNotFound = errors.New("error: key not found") // ErrKeyExpired is the error returned when a key is queried which has // already expired (due to ttl) ErrKeyExpired = errors.New("error: key expired") // ErrEmptyKey is the error returned for a value with an empty key. ErrEmptyKey = errors.New("error: empty key") // ErrDatabaseLocked is the error returned if the database is locked // (typically opened by another process) ErrDatabaseLocked = errors.New("error: database locked") // ErrInvalidRange is the error returned when the range scan is invalid ErrInvalidRange = errors.New("error: invalid range") // ErrMergeInProgress is the error returned if merge is called when already a merge // is in progress ErrMergeInProgress = errors.New("error: merge already in progress") )
This section is empty.
type Bitcask struct {
// contains filtered or unexported fields
}
Bitcask is a struct that represents a on-disk LSM and WAL data structure and in-memory hash of key/value pairs as per the Bitcask paper and seen in the Riak database.
func Open(path string, funcs ...OptionFunc) (*Bitcask, error)
Open opens the database at the given path with optional options. Options can be provided with the `WithXXX` functions that provide configuration options as functions.
Close closes the database and removes the lock. It is important to call Close() as this is the only way to cleanup the lock held by the open database.
DeleteAll deletes all the keys. If an I/O error occurs the error is returned.
func (b *Bitcask) Get(key []byte) (io.ReadCloser, error)
Get fetches value for a key
Merge merges all datafiles in the database. Old keys are squashed and deleted keys removes. Duplicate key/value pairs are also removed. Call this function periodically to reclaim disk space.
PutWithTTL stores the key and value in the database with the given TTL
Range performs a range scan of keys matching a range of keys between the start key and end key and calling the function `f` with the keys found. If the function returns an error no further keys are processed and the first error returned.
Scan performs a prefix scan of keys matching the given prefix and calling the function `f` with the keys found. If the function returns an error no further keys are processed and the first error is returned.
type OptionFunc func(*option) error
Option is a function that takes a option struct and modifies it
func WithCopyTempThreshold(size int64) OptionFunc
func WithDirFileModeBeforeUmask(mode os.FileMode) OptionFunc
WithDirFileModeBeforeUmask sets the FileMode used for each new file created.
func WithFileFileModeBeforeUmask(mode os.FileMode) OptionFunc
WithFileFileModeBeforeUmask sets the FileMode used for each new file created.
func WithLogger(logger *log.Logger) OptionFunc
func WithMaxDatafileSize(size int) OptionFunc
WithMaxDatafileSize sets the maximum datafile size option
func WithRepli(bindIP string, bindPort int) OptionFunc
func WithRepliClient(serverIP string, serverPort int) OptionFunc
func WithRepliClientRequestTimeout(rto time.Duration) OptionFunc
func WithRuntimeContext(ctx runtime.Context) OptionFunc
func WithSync(sync bool) OptionFunc
WithSync causes Sync() to be called on every key/value written increasing durability and safety at the expense of performance
func WithTempDir(dir string) OptionFunc
func WithValidateChecksum(enable bool) OptionFunc
| Back | FazBrowse Home | New Git URL |