open key-database deterministic

This commit is contained in:
6543 2021-12-03 04:15:48 +01:00
parent 796f24262e
commit 5ca5020cfa
No known key found for this signature in database
GPG key ID: C99B82E40B027BAE
8 changed files with 94 additions and 48 deletions

19
server/database/setup.go Normal file
View file

@ -0,0 +1,19 @@
package database
import (
"fmt"
"github.com/akrylysov/pogreb"
"github.com/akrylysov/pogreb/fs"
"time"
)
func New(path string) (KeyDB, error) {
if path == "" {
return nil, fmt.Errorf("path not set")
}
return pogreb.Open(path, &pogreb.Options{
BackgroundSyncInterval: 30 * time.Second,
BackgroundCompactionInterval: 6 * time.Hour,
FileSystem: fs.OSMMap,
})
}