lmdv add nosync config, fix hyperleveldb build bug

This commit is contained in:
siddontang 2014-08-15 10:46:48 +08:00
parent 34f1795a5f
commit a3f402c6bd
7 changed files with 18 additions and 3 deletions

View File

@ -34,7 +34,8 @@ type LevelDBConfig struct {
}
type LMDBConfig struct {
MapSize int `toml:"map_size" json:"map_size"`
MapSize int `toml:"map_size" json:"map_size"`
NoSync bool `toml:"nosync" json:"nosync"`
}
type BinLogConfig struct {

View File

@ -14,7 +14,8 @@
},
"lmdb" : {
"map_size" : 524288000
"map_size" : 524288000,
"nosync" : true
},
"access_log" : ""

View File

@ -34,6 +34,7 @@ max_open_files = 1024
[lmdb]
map_size = 524288000
nosync = true
[binlog]
max_file_size = 0

View File

@ -36,6 +36,7 @@ max_open_files = 1024
[lmdb]
map_size = 524288000
nosync = true
[binlog]
# Set either size or num to 0 to disable binlog

View File

@ -1,3 +1,5 @@
// +build hyperleveldb
package store
import (

View File

@ -1,3 +1,5 @@
// +build hyperleveldb
package store
import (

View File

@ -23,6 +23,8 @@ type MDB struct {
func (s Store) Open(path string, c *config.Config) (driver.IDB, error) {
mapSize := c.LMDB.MapSize
noSync := c.LMDB.NoSync
if mapSize <= 0 {
mapSize = 500 * 1024 * 1024
}
@ -48,7 +50,12 @@ func (s Store) Open(path string, c *config.Config) (driver.IDB, error) {
}
}
err = env.Open(path, mdb.NOSYNC|mdb.NOMETASYNC|mdb.WRITEMAP|mdb.MAPASYNC|mdb.CREATE, 0755)
var flags uint = mdb.CREATE
if noSync {
flags |= mdb.NOSYNC | mdb.NOMETASYNC | mdb.WRITEMAP | mdb.MAPASYNC
}
err = env.Open(path, flags, 0755)
if err != nil {
return MDB{}, err
}