Skip to content

Commit

Permalink
add housekeep
Browse files Browse the repository at this point in the history
  • Loading branch information
codchen committed Mar 29, 2023
1 parent 8deee58 commit 61dacea
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions prefixdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package db
import (
"fmt"
"sync"

"github.com/syndtr/goleveldb/leveldb/util"
)

// PrefixDB wraps a namespace of another database as a logical database.
Expand Down Expand Up @@ -180,6 +182,13 @@ func (pdb *PrefixDB) Stats() map[string]string {
return stats
}

func (pdb *PrefixDB) Housekeep() error {
if goleveldb, ok := pdb.db.(*GoLevelDB); ok {
return goleveldb.DB().CompactRange(util.Range{Start: nil, Limit: nil})
}
return nil
}

func (pdb *PrefixDB) prefixed(key []byte) []byte {
return append(cp(pdb.prefix), key...)
}

0 comments on commit 61dacea

Please sign in to comment.