package writecache import ( "io/fs" "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, openFile func(string, int, fs.FileMode) (*os.File, error), pageSize int) (*bbolt.DB, error) { return bbolt.Open(filepath.Join(p, dbName), os.ModePerm, &bbolt.Options{ NoFreelistSync: true, ReadOnly: ro, Timeout: 100 * time.Millisecond, OpenFile: openFile, PageSize: pageSize, }) }