4e361e2ab4
Close #1647. Initially, `Sync: false` was provided because we can already lose objects cached in memory. However, future changes in writecache will remove inmemory cache and speed up it via other means. Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
18 lines
392 B
Go
18 lines
392 B
Go
package writecache
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"time"
|
|
|
|
"go.etcd.io/bbolt"
|
|
)
|
|
|
|
// OpenDB opens BoltDB instance for write-cache. Opens in read-only mode if ro is true.
|
|
func OpenDB(p string, ro bool) (*bbolt.DB, error) {
|
|
return bbolt.Open(filepath.Join(p, dbName), os.ModePerm, &bbolt.Options{
|
|
NoFreelistSync: true,
|
|
ReadOnly: ro,
|
|
Timeout: 100 * time.Millisecond,
|
|
})
|
|
}
|