2021-09-14 16:20:31 +00:00
|
|
|
package writecache
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2022-02-02 13:28:08 +00:00
|
|
|
"path/filepath"
|
2022-06-09 11:08:13 +00:00
|
|
|
"time"
|
2021-09-14 16:20:31 +00:00
|
|
|
|
|
|
|
"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) {
|
2022-02-02 13:28:08 +00:00
|
|
|
return bbolt.Open(filepath.Join(p, dbName), os.ModePerm, &bbolt.Options{
|
2021-09-14 16:20:31 +00:00
|
|
|
NoFreelistSync: true,
|
|
|
|
NoSync: true,
|
|
|
|
ReadOnly: ro,
|
2022-06-09 11:08:13 +00:00
|
|
|
Timeout: 100 * time.Millisecond,
|
2021-09-14 16:20:31 +00:00
|
|
|
})
|
|
|
|
}
|