diff --git a/prefixdb.go b/prefixdb.go index 447ce2e..e5aaa44 100644 --- a/prefixdb.go +++ b/prefixdb.go @@ -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. @@ -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...) }