mirror of
https://github.com/gogrlx/bitcask.git
synced 2026-04-17 02:25:04 -07:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3b1a02371 | ||
|
|
7149cb9afe | ||
|
|
c593bc966f | ||
|
|
2400dd86d5 | ||
|
|
27eb922ba2 | ||
|
|
34ad78efc0 | ||
|
|
352c32ee12 | ||
|
|
aaea7273c3 | ||
|
|
01cb269a51 |
81
bitcask.go
81
bitcask.go
@@ -8,6 +8,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/gofrs/flock"
|
"github.com/gofrs/flock"
|
||||||
"github.com/prologic/trie"
|
"github.com/prologic/trie"
|
||||||
@@ -16,14 +17,32 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrKeyNotFound = errors.New("error: key not found")
|
// ErrKeyNotFound is the error returned when a key is not found
|
||||||
ErrKeyTooLarge = errors.New("error: key too large")
|
ErrKeyNotFound = errors.New("error: key not found")
|
||||||
ErrValueTooLarge = errors.New("error: value too large")
|
|
||||||
|
// ErrKeyTooLarge is the error returned for a key that exceeds the
|
||||||
|
// maximum allowed key size (configured with WithMaxKeySize).
|
||||||
|
ErrKeyTooLarge = errors.New("error: key too large")
|
||||||
|
|
||||||
|
// ErrValueTooLarge is the error returned for a value that exceeds the
|
||||||
|
// maximum allowed value size (configured with WithMaxValueSize).
|
||||||
|
ErrValueTooLarge = errors.New("error: value too large")
|
||||||
|
|
||||||
|
// ErrChecksumFailed is the error returned if a key/valie retrieved does
|
||||||
|
// not match its CRC checksum
|
||||||
ErrChecksumFailed = errors.New("error: checksum failed")
|
ErrChecksumFailed = errors.New("error: checksum failed")
|
||||||
|
|
||||||
|
// ErrDatabaseLocked is the error returned if the database is locked
|
||||||
|
// (typically opened by another process)
|
||||||
ErrDatabaseLocked = errors.New("error: database locked")
|
ErrDatabaseLocked = errors.New("error: database locked")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 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.
|
||||||
type Bitcask struct {
|
type Bitcask struct {
|
||||||
|
mu sync.RWMutex
|
||||||
|
|
||||||
*flock.Flock
|
*flock.Flock
|
||||||
|
|
||||||
config *config
|
config *config
|
||||||
@@ -32,10 +51,11 @@ type Bitcask struct {
|
|||||||
keydir *internal.Keydir
|
keydir *internal.Keydir
|
||||||
datafiles []*internal.Datafile
|
datafiles []*internal.Datafile
|
||||||
trie *trie.Trie
|
trie *trie.Trie
|
||||||
|
|
||||||
maxDatafileSize int64
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close closes the database and removes the lock. It is important to call
|
||||||
|
// Close() as this is the only wat to cleanup the lock held by the open
|
||||||
|
// database.
|
||||||
func (b *Bitcask) Close() error {
|
func (b *Bitcask) Close() error {
|
||||||
defer func() {
|
defer func() {
|
||||||
b.Flock.Unlock()
|
b.Flock.Unlock()
|
||||||
@@ -48,10 +68,13 @@ func (b *Bitcask) Close() error {
|
|||||||
return b.curr.Close()
|
return b.curr.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sync flushes all buffers to disk ensuring all data is written
|
||||||
func (b *Bitcask) Sync() error {
|
func (b *Bitcask) Sync() error {
|
||||||
return b.curr.Sync()
|
return b.curr.Sync()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get retrieves the value of the given key. If the key is not found or an/I/O
|
||||||
|
// error occurs a null byte slice is returend along with the error.
|
||||||
func (b *Bitcask) Get(key string) ([]byte, error) {
|
func (b *Bitcask) Get(key string) ([]byte, error) {
|
||||||
var df *internal.Datafile
|
var df *internal.Datafile
|
||||||
|
|
||||||
@@ -79,16 +102,18 @@ func (b *Bitcask) Get(key string) ([]byte, error) {
|
|||||||
return e.Value, nil
|
return e.Value, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Has returns true if the key exists in the database, false otherwise.
|
||||||
func (b *Bitcask) Has(key string) bool {
|
func (b *Bitcask) Has(key string) bool {
|
||||||
_, ok := b.keydir.Get(key)
|
_, ok := b.keydir.Get(key)
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Put stores the key and value in the database.
|
||||||
func (b *Bitcask) Put(key string, value []byte) error {
|
func (b *Bitcask) Put(key string, value []byte) error {
|
||||||
if len(key) > b.config.MaxKeySize {
|
if len(key) > b.config.maxKeySize {
|
||||||
return ErrKeyTooLarge
|
return ErrKeyTooLarge
|
||||||
}
|
}
|
||||||
if len(value) > b.config.MaxValueSize {
|
if len(value) > b.config.maxValueSize {
|
||||||
return ErrValueTooLarge
|
return ErrValueTooLarge
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,6 +128,8 @@ func (b *Bitcask) Put(key string, value []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete deletes the named key. If the key doesn't exist or an I/O error
|
||||||
|
// occurs the error is returned.
|
||||||
func (b *Bitcask) Delete(key string) error {
|
func (b *Bitcask) Delete(key string) error {
|
||||||
_, err := b.put(key, []byte{})
|
_, err := b.put(key, []byte{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -115,6 +142,9 @@ func (b *Bitcask) Delete(key string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Scan performa 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 returned.
|
||||||
func (b *Bitcask) Scan(prefix string, f func(key string) error) error {
|
func (b *Bitcask) Scan(prefix string, f func(key string) error) error {
|
||||||
keys := b.trie.PrefixSearch(prefix)
|
keys := b.trie.PrefixSearch(prefix)
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
@@ -125,6 +155,19 @@ func (b *Bitcask) Scan(prefix string, f func(key string) error) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Len returns the total number of keys in the database
|
||||||
|
func (b *Bitcask) Len() int {
|
||||||
|
return b.keydir.Len()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keys returns all keys in the database as a channel of string(s)
|
||||||
|
func (b *Bitcask) Keys() chan string {
|
||||||
|
return b.keydir.Keys()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fold iterates over all keys in the database calling the function `f` for
|
||||||
|
// each key. If the function returns an error, no further keys are processed
|
||||||
|
// and the error returned.
|
||||||
func (b *Bitcask) Fold(f func(key string) error) error {
|
func (b *Bitcask) Fold(f func(key string) error) error {
|
||||||
for key := range b.keydir.Keys() {
|
for key := range b.keydir.Keys() {
|
||||||
if err := f(key); err != nil {
|
if err := f(key); err != nil {
|
||||||
@@ -135,12 +178,11 @@ func (b *Bitcask) Fold(f func(key string) error) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bitcask) put(key string, value []byte) (int64, error) {
|
func (b *Bitcask) put(key string, value []byte) (int64, error) {
|
||||||
size, err := b.curr.Size()
|
b.mu.Lock()
|
||||||
if err != nil {
|
defer b.mu.Unlock()
|
||||||
return -1, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if size >= b.maxDatafileSize {
|
size := b.curr.Size()
|
||||||
|
if size >= int64(b.config.maxDatafileSize) {
|
||||||
err := b.curr.Close()
|
err := b.curr.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return -1, err
|
return -1, err
|
||||||
@@ -165,11 +207,9 @@ func (b *Bitcask) put(key string, value []byte) (int64, error) {
|
|||||||
return b.curr.Write(e)
|
return b.curr.Write(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bitcask) setMaxDatafileSize(size int64) error {
|
// Merge merges all datafiles in the database creating hint files for faster
|
||||||
b.maxDatafileSize = size
|
// startup. Old keys are squashed and deleted keys removes. Call this function
|
||||||
return nil
|
// periodically to reclaim disk space.
|
||||||
}
|
|
||||||
|
|
||||||
func Merge(path string, force bool) error {
|
func Merge(path string, force bool) error {
|
||||||
fns, err := internal.GetDatafiles(path)
|
fns, err := internal.GetDatafiles(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -276,7 +316,10 @@ func Merge(path string, force bool) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Open(path string, options ...option) (*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.
|
||||||
|
func Open(path string, options ...Option) (*Bitcask, error) {
|
||||||
if err := os.MkdirAll(path, 0755); err != nil {
|
if err := os.MkdirAll(path, 0755); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -365,8 +408,6 @@ func Open(path string, options ...option) (*Bitcask, error) {
|
|||||||
keydir: keydir,
|
keydir: keydir,
|
||||||
datafiles: datafiles,
|
datafiles: datafiles,
|
||||||
trie: trie,
|
trie: trie,
|
||||||
|
|
||||||
maxDatafileSize: DefaultMaxDatafileSize,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, opt := range options {
|
for _, opt := range options {
|
||||||
|
|||||||
@@ -40,10 +40,22 @@ func TestAll(t *testing.T) {
|
|||||||
assert.Equal([]byte("bar"), val)
|
assert.Equal([]byte("bar"), val)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("Len", func(t *testing.T) {
|
||||||
|
assert.Equal(1, db.Len())
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("Has", func(t *testing.T) {
|
t.Run("Has", func(t *testing.T) {
|
||||||
assert.True(db.Has("foo"))
|
assert.True(db.Has("foo"))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("Keys", func(t *testing.T) {
|
||||||
|
keys := make([]string, 0)
|
||||||
|
for key := range db.Keys() {
|
||||||
|
keys = append(keys, key)
|
||||||
|
}
|
||||||
|
assert.Equal([]string{"foo"}, keys)
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("Fold", func(t *testing.T) {
|
t.Run("Fold", func(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
keys []string
|
keys []string
|
||||||
|
|||||||
@@ -96,6 +96,22 @@ func main() {
|
|||||||
} else {
|
} else {
|
||||||
conn.WriteBulk(value)
|
conn.WriteBulk(value)
|
||||||
}
|
}
|
||||||
|
case "keys":
|
||||||
|
conn.WriteArray(db.Len())
|
||||||
|
for key := range db.Keys() {
|
||||||
|
conn.WriteBulk([]byte(key))
|
||||||
|
}
|
||||||
|
case "exists":
|
||||||
|
if len(cmd.Args) != 2 {
|
||||||
|
conn.WriteError("ERR wrong number of arguments for '" + string(cmd.Args[0]) + "' command")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
key := string(cmd.Args[1])
|
||||||
|
if db.Has(key) {
|
||||||
|
conn.WriteInt(1)
|
||||||
|
} else {
|
||||||
|
conn.WriteInt(0)
|
||||||
|
}
|
||||||
case "del":
|
case "del":
|
||||||
if len(cmd.Args) != 2 {
|
if len(cmd.Args) != 2 {
|
||||||
conn.WriteError("ERR wrong number of arguments for '" + string(cmd.Args[0]) + "' command")
|
conn.WriteError("ERR wrong number of arguments for '" + string(cmd.Args[0]) + "' command")
|
||||||
|
|||||||
23
go.mod
23
go.mod
@@ -2,17 +2,28 @@ module github.com/prologic/bitcask
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/BurntSushi/toml v0.3.1 // indirect
|
github.com/BurntSushi/toml v0.3.1 // indirect
|
||||||
|
github.com/coreos/etcd v3.3.12+incompatible // indirect
|
||||||
github.com/gofrs/flock v0.7.1
|
github.com/gofrs/flock v0.7.1
|
||||||
github.com/gogo/protobuf v1.2.1
|
github.com/gogo/protobuf v1.2.1
|
||||||
github.com/golang/protobuf v1.2.0
|
github.com/golang/protobuf v1.3.1
|
||||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||||
|
github.com/kisielk/errcheck v1.2.0 // indirect
|
||||||
|
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
|
||||||
github.com/pkg/errors v0.8.1
|
github.com/pkg/errors v0.8.1
|
||||||
github.com/prologic/trie v0.0.0-20190316011403-395e39dac705
|
github.com/prologic/trie v0.0.0-20190322091023-3972df81f9b5
|
||||||
github.com/sirupsen/logrus v1.3.0
|
github.com/sirupsen/logrus v1.4.0
|
||||||
|
github.com/spf13/afero v1.2.1 // indirect
|
||||||
github.com/spf13/cobra v0.0.3
|
github.com/spf13/cobra v0.0.3
|
||||||
|
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||||
github.com/spf13/pflag v1.0.3
|
github.com/spf13/pflag v1.0.3
|
||||||
github.com/spf13/viper v1.3.1
|
github.com/spf13/viper v1.3.2
|
||||||
github.com/stretchr/testify v1.3.0
|
github.com/stretchr/testify v1.3.0
|
||||||
github.com/tidwall/redcon v0.9.0
|
github.com/tidwall/redcon v1.0.0
|
||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f // indirect
|
github.com/ugorji/go/codec v0.0.0-20190320090025-2dc34c0b8780 // indirect
|
||||||
|
golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576 // indirect
|
||||||
|
golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53 // indirect
|
||||||
|
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 // indirect
|
||||||
|
golang.org/x/sys v0.0.0-20190322080309-f49334f85ddc // indirect
|
||||||
|
golang.org/x/tools v0.0.0-20190321232350-e250d351ecad // indirect
|
||||||
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
31
go.sum
31
go.sum
@@ -2,6 +2,7 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ
|
|||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||||
|
github.com/coreos/etcd v3.3.12+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||||
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
@@ -16,14 +17,18 @@ github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE=
|
|||||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||||
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
|
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
|
||||||
|
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||||
|
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
|
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
|
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
|
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
|
||||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||||
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
|
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
|
||||||
@@ -36,20 +41,30 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
|||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/prologic/trie v0.0.0-20190316011403-395e39dac705 h1:2J+cSlAeECj0lfMKSmM7n5OlIio+yLovaKLZJzwLc6U=
|
github.com/prologic/trie v0.0.0-20190316011403-395e39dac705 h1:2J+cSlAeECj0lfMKSmM7n5OlIio+yLovaKLZJzwLc6U=
|
||||||
github.com/prologic/trie v0.0.0-20190316011403-395e39dac705/go.mod h1:LFuDmpHJGmciXd8Rl5YMhVlLMps9gz2GtYLzwxrFhzs=
|
github.com/prologic/trie v0.0.0-20190316011403-395e39dac705/go.mod h1:LFuDmpHJGmciXd8Rl5YMhVlLMps9gz2GtYLzwxrFhzs=
|
||||||
|
github.com/prologic/trie v0.0.0-20190322091023-3972df81f9b5 h1:H8dTZzU3aWNQnuRyiT45J9szv7EFakAhFzsFq27t3Uo=
|
||||||
|
github.com/prologic/trie v0.0.0-20190322091023-3972df81f9b5/go.mod h1:LFuDmpHJGmciXd8Rl5YMhVlLMps9gz2GtYLzwxrFhzs=
|
||||||
github.com/sirupsen/logrus v1.3.0 h1:hI/7Q+DtNZ2kINb6qt/lS+IyXnHQe9e90POfeewL/ME=
|
github.com/sirupsen/logrus v1.3.0 h1:hI/7Q+DtNZ2kINb6qt/lS+IyXnHQe9e90POfeewL/ME=
|
||||||
github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||||
|
github.com/sirupsen/logrus v1.4.0 h1:yKenngtzGh+cUSSh6GWbxW2abRqhYUSR/t/6+2QqNvE=
|
||||||
|
github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||||
github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
|
github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
|
||||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||||
|
github.com/spf13/afero v1.2.1 h1:qgMbHoJbPbw579P+1zVY+6n4nIFuIchaIjzZ/I/Yq8M=
|
||||||
|
github.com/spf13/afero v1.2.1/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
|
||||||
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
|
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
|
||||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||||
github.com/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8=
|
github.com/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8=
|
||||||
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
||||||
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
|
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
|
||||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||||
|
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
|
||||||
|
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
|
||||||
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
|
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
|
||||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||||
github.com/spf13/viper v1.3.1 h1:5+8j8FTpnFV4nEImW/ofkzEt8VoOiLXxdYIDsB73T38=
|
github.com/spf13/viper v1.3.1 h1:5+8j8FTpnFV4nEImW/ofkzEt8VoOiLXxdYIDsB73T38=
|
||||||
github.com/spf13/viper v1.3.1/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
github.com/spf13/viper v1.3.1/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||||
|
github.com/spf13/viper v1.3.2 h1:VUFqw5KcqRf7i70GOzW7N+Q7+gxVBkSSqiXB12+JQ4M=
|
||||||
|
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
@@ -57,20 +72,36 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0
|
|||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/tidwall/redcon v0.9.0 h1:tiT9DLAoohsdNaFg9Si5dRsv9+FjvZYnhMOEtSFwBqA=
|
github.com/tidwall/redcon v0.9.0 h1:tiT9DLAoohsdNaFg9Si5dRsv9+FjvZYnhMOEtSFwBqA=
|
||||||
github.com/tidwall/redcon v0.9.0/go.mod h1:bdYBm4rlcWpst2XMwKVzWDF9CoUxEbUmM7CQrKeOZas=
|
github.com/tidwall/redcon v0.9.0/go.mod h1:bdYBm4rlcWpst2XMwKVzWDF9CoUxEbUmM7CQrKeOZas=
|
||||||
|
github.com/tidwall/redcon v1.0.0 h1:D4AzzJ81Afeh144fgnj5H0aSVPBBJ5RI9Rzj0zThU+E=
|
||||||
|
github.com/tidwall/redcon v1.0.0/go.mod h1:bdYBm4rlcWpst2XMwKVzWDF9CoUxEbUmM7CQrKeOZas=
|
||||||
|
github.com/ugorji/go v1.1.2/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
|
||||||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||||
|
github.com/ugorji/go/codec v0.0.0-20190320090025-2dc34c0b8780/go.mod h1:iT03XoTwV7xq/+UGwKO3UbC1nNNlopQiY61beSdrtOA=
|
||||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 h1:mKdxBk7AujPs8kU4m80U72y/zjbZ3UcXC7dClwKbUI0=
|
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 h1:mKdxBk7AujPs8kU4m80U72y/zjbZ3UcXC7dClwKbUI0=
|
||||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576 h1:aUX/1G2gFSs4AsJJg2cL3HuoRhCSCz733FE5GUSuaT4=
|
||||||
|
golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ=
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ=
|
||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a h1:1n5lsVfiQW3yfsRGu98756EH1YthsFqr/5mxHduZW2A=
|
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a h1:1n5lsVfiQW3yfsRGu98756EH1YthsFqr/5mxHduZW2A=
|
||||||
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190322080309-f49334f85ddc h1:4gbWbmmPFp4ySWICouJl6emP0MyS31yy9SrTlAGFT+g=
|
||||||
|
golang.org/x/sys v0.0.0-20190322080309-f49334f85ddc/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20190321232350-e250d351ecad/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
|||||||
@@ -98,10 +98,10 @@ func (df *Datafile) Sync() error {
|
|||||||
return df.w.Sync()
|
return df.w.Sync()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (df *Datafile) Size() (int64, error) {
|
func (df *Datafile) Size() int64 {
|
||||||
df.RLock()
|
df.RLock()
|
||||||
defer df.RUnlock()
|
defer df.RUnlock()
|
||||||
return df.offset, nil
|
return df.offset
|
||||||
}
|
}
|
||||||
|
|
||||||
func (df *Datafile) Read() (e pb.Entry, err error) {
|
func (df *Datafile) Read() (e pb.Entry, err error) {
|
||||||
|
|||||||
@@ -52,11 +52,17 @@ func (k *Keydir) Delete(key string) {
|
|||||||
delete(k.kv, key)
|
delete(k.kv, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (k *Keydir) Len() int {
|
||||||
|
return len(k.kv)
|
||||||
|
}
|
||||||
|
|
||||||
func (k *Keydir) Keys() chan string {
|
func (k *Keydir) Keys() chan string {
|
||||||
ch := make(chan string)
|
ch := make(chan string)
|
||||||
go func() {
|
go func() {
|
||||||
for k := range k.kv {
|
k.RLock()
|
||||||
ch <- k
|
defer k.RUnlock()
|
||||||
|
for key := range k.kv {
|
||||||
|
ch <- key
|
||||||
}
|
}
|
||||||
close(ch)
|
close(ch)
|
||||||
}()
|
}()
|
||||||
|
|||||||
42
options.go
42
options.go
@@ -1,47 +1,53 @@
|
|||||||
package bitcask
|
package bitcask
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// DefaultMaxDatafileSize is the default maximum datafile size in bytes
|
||||||
DefaultMaxDatafileSize = 1 << 20 // 1MB
|
DefaultMaxDatafileSize = 1 << 20 // 1MB
|
||||||
DefaultMaxKeySize = 64 // 64 bytes
|
|
||||||
DefaultMaxValueSize = 1 << 16 // 65KB
|
// DefaultMaxKeySize is the default maximum key size in bytes
|
||||||
|
DefaultMaxKeySize = 64 // 64 bytes
|
||||||
|
|
||||||
|
// DefaultMaxValueSize is the default value size in bytes
|
||||||
|
DefaultMaxValueSize = 1 << 16 // 65KB
|
||||||
)
|
)
|
||||||
|
|
||||||
// Option ...
|
// Option is a function that takes a config struct and modifies it
|
||||||
type Option option
|
type Option func(*config) error
|
||||||
|
|
||||||
type option func(*config) error
|
|
||||||
|
|
||||||
type config struct {
|
type config struct {
|
||||||
MaxDatafileSize int
|
maxDatafileSize int
|
||||||
MaxKeySize int
|
maxKeySize int
|
||||||
MaxValueSize int
|
maxValueSize int
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDefaultConfig() *config {
|
func newDefaultConfig() *config {
|
||||||
return &config{
|
return &config{
|
||||||
MaxDatafileSize: DefaultMaxDatafileSize,
|
maxDatafileSize: DefaultMaxDatafileSize,
|
||||||
MaxKeySize: DefaultMaxKeySize,
|
maxKeySize: DefaultMaxKeySize,
|
||||||
MaxValueSize: DefaultMaxValueSize,
|
maxValueSize: DefaultMaxValueSize,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithMaxDatafileSize(size int) option {
|
// WithMaxDatafileSize sets the maximum datafile size option
|
||||||
|
func WithMaxDatafileSize(size int) Option {
|
||||||
return func(cfg *config) error {
|
return func(cfg *config) error {
|
||||||
cfg.MaxDatafileSize = size
|
cfg.maxDatafileSize = size
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithMaxKeySize(size int) option {
|
// WithMaxKeySize sets the maximum key size option
|
||||||
|
func WithMaxKeySize(size int) Option {
|
||||||
return func(cfg *config) error {
|
return func(cfg *config) error {
|
||||||
cfg.MaxKeySize = size
|
cfg.maxKeySize = size
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithMaxValueSize(size int) option {
|
// WithMaxValueSize sets the maximum value size option
|
||||||
|
func WithMaxValueSize(size int) Option {
|
||||||
return func(cfg *config) error {
|
return func(cfg *config) error {
|
||||||
cfg.MaxValueSize = size
|
cfg.maxValueSize = size
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user