Skip to content

Commit

Permalink
Add NoSync field to Options
Browse files Browse the repository at this point in the history
This allows enabling NoSync when you only have access to the Options
passed into Open() and not the returned DB (as is frequently the case
with libraries).
  • Loading branch information
tylertreat committed Aug 24, 2017
1 parent 9c39199 commit 69fa13f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func Open(path string, mode os.FileMode, options *Options) (*DB, error) {
if options == nil {
options = DefaultOptions
}
db.NoSync = options.NoSync
db.NoGrowSync = options.NoGrowSync
db.MmapFlags = options.MmapFlags
db.NoFreelistSync = options.NoFreelistSync
Expand Down Expand Up @@ -1008,6 +1009,11 @@ type Options struct {

// PageSize overrides the default OS page size.
PageSize int

// NoSync sets the initial value of DB.NoSync. Normally this can just be
// set directly on the DB itself when returned from Open(), but this option
// is useful in APIs which expose Options but not the underlying DB.
NoSync bool
}

// DefaultOptions represent the options used if nil options are passed into Open().
Expand Down

0 comments on commit 69fa13f

Please sign in to comment.