mirror of https://github.com/tidwall/buntdb.git
Add support for explicit Sync
This commit is contained in:
parent
71088bcabf
commit
69bc59c5bc
14
buntdb.go
14
buntdb.go
|
@ -628,6 +628,20 @@ func (db *DB) backgroundManager() {
|
|||
}
|
||||
}
|
||||
|
||||
// Sync will synchronously persist the database file to disk. This
|
||||
// should only be used when [SyncPolicy] is set to [Never].
|
||||
func (db *DB) Sync() error {
|
||||
db.mu.Lock()
|
||||
defer db.mu.Unlock()
|
||||
if db.closed {
|
||||
return ErrDatabaseClosed
|
||||
}
|
||||
if !db.persist {
|
||||
return nil
|
||||
}
|
||||
return db.file.Sync()
|
||||
}
|
||||
|
||||
// Shrink will make the database file smaller by removing redundant
|
||||
// log entries. This operation does not block the database.
|
||||
func (db *DB) Shrink() error {
|
||||
|
|
Loading…
Reference in New Issue