mirror of
https://github.com/gogrlx/bitcask.git
synced 2026-04-02 02:58:59 -07:00
12
bitcask.go
12
bitcask.go
@@ -125,6 +125,11 @@ func (b *Bitcask) close() error {
|
||||
func (b *Bitcask) Sync() error {
|
||||
b.mu.RLock()
|
||||
defer b.mu.RUnlock()
|
||||
|
||||
if err := b.saveMetadata(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return b.curr.Sync()
|
||||
}
|
||||
|
||||
@@ -201,12 +206,7 @@ func (b *Bitcask) Put(key, value []byte) error {
|
||||
}
|
||||
|
||||
// in case of successful `put`, IndexUpToDate will be always be false
|
||||
if b.metadata.IndexUpToDate {
|
||||
b.metadata.IndexUpToDate = false
|
||||
if err := b.saveMetadata(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
b.metadata.IndexUpToDate = false
|
||||
|
||||
if oldItem, found := b.trie.Search(key); found {
|
||||
b.metadata.ReclaimableSpace += oldItem.(internal.Item).Size
|
||||
|
||||
Reference in New Issue
Block a user