Skip to content

Commit

Permalink
opt: fix 'cacher' options
Browse files Browse the repository at this point in the history
fixes #286
  • Loading branch information
syndtr committed Aug 15, 2020
1 parent a80b7c2 commit d415f1b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
9 changes: 1 addition & 8 deletions leveldb/opt/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,12 @@ type CacherFunc struct {
}

func (f *CacherFunc) New(capacity int) cache.Cacher {
if f.NewFunc != nil {
if f != nil && f.NewFunc != nil {
return f.NewFunc(capacity)
}
return nil
}

func noCacher(int) cache.Cacher { return nil }

var (
// LRUCacher is the LRU-cache algorithm.
LRUCacher = &CacherFunc{cache.NewLRU}
Expand Down Expand Up @@ -390,8 +388,6 @@ func (o *Options) GetAltFilters() []filter.Filter {
func (o *Options) GetBlockCacher() Cacher {
if o == nil || o.BlockCacher == nil {
return DefaultBlockCacher
} else if o.BlockCacher == NoCacher {
return nil
}
return o.BlockCacher
}
Expand Down Expand Up @@ -596,9 +592,6 @@ func (o *Options) GetOpenFilesCacher() Cacher {
if o == nil || o.OpenFilesCacher == nil {
return DefaultOpenFilesCacher
}
if o.OpenFilesCacher == NoCacher {
return nil
}
return o.OpenFilesCacher
}

Expand Down
2 changes: 1 addition & 1 deletion leveldb/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ func newTableOps(s *session) *tOps {
bpool *util.BufferPool
)
if s.o.GetOpenFilesCacheCapacity() > 0 {
cacher = cache.NewLRU(s.o.GetOpenFilesCacheCapacity())
cacher = s.o.GetOpenFilesCacher().New(s.o.GetOpenFilesCacheCapacity())
}
if !s.o.GetDisableBlockCache() {
var bcacher cache.Cacher
Expand Down

0 comments on commit d415f1b

Please sign in to comment.