From 69fa13f2f18c24cf3a9d5bb098fc895eec324fef Mon Sep 17 00:00:00 2001 From: Tyler Treat Date: Thu, 24 Aug 2017 09:35:24 -0700 Subject: [PATCH] Add NoSync field to Options 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). --- db.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/db.go b/db.go index 71933cb..4730368 100644 --- a/db.go +++ b/db.go @@ -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 @@ -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().