Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
feat: make gc log humanize
Browse files Browse the repository at this point in the history
  • Loading branch information
maolonglong committed Feb 20, 2022
1 parent afcc0bb commit 5b50aa0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
3 changes: 1 addition & 2 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package redix

import (
"context"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -198,7 +197,7 @@ func (s *Server) cmdFLUSHALL(c *Context) {
return
}

err := s.store.FlushAll(context.Background())
err := s.store.DropAll()
if err != nil {
s.logUnknownError("store.FlushAll", err)
c.ErrUnknown(err)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.17
require (
github.com/dgraph-io/badger/v3 v3.2103.2
github.com/dgraph-io/ristretto v0.1.0
github.com/dustin/go-humanize v1.0.0
github.com/spf13/viper v1.10.1
github.com/stretchr/testify v1.7.0
github.com/tidwall/evio v1.0.8
Expand All @@ -17,7 +18,6 @@ require (
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect
Expand Down
8 changes: 4 additions & 4 deletions pkg/storage/badger/badger.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
package badger

import (
"context"
"time"

"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/ristretto/z"
"github.com/dustin/go-humanize"
"github.com/tidwall/match"
"go.chensl.me/redix/internal/bytesconv"
"go.chensl.me/redix/pkg/storage"
Expand Down Expand Up @@ -86,7 +86,7 @@ func (s *badgerStorage) Del(keys ...[]byte) (int, error) {
return cnt, err
}

func (s *badgerStorage) FlushAll(_ context.Context) error {
func (s *badgerStorage) DropAll() error {
return s.db.DropAll()
}

Expand Down Expand Up @@ -152,8 +152,8 @@ func (s *badgerStorage) runValueLogGC() {
}
lsm, vlog := s.db.Size()
s.logger.Info("running value log GC",
zap.Int64("lsm", lsm),
zap.Int64("vlog", vlog),
zap.String("lsm", humanize.Bytes(uint64(lsm))),
zap.String("vlog", humanize.Bytes(uint64(vlog))),
)
again:
err := s.db.RunValueLogGC(0.7)
Expand Down
3 changes: 1 addition & 2 deletions pkg/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package storage

import (
"context"
"time"
)

Expand All @@ -16,7 +15,7 @@ type Interface interface {
Del(keys ...[]byte) (int, error)
Expire(key []byte, dur time.Duration) error
TTL(key []byte) (int64, error)
FlushAll(ctx context.Context) error
DropAll() error
Close() error
}

Expand Down

0 comments on commit 5b50aa0

Please sign in to comment.