-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
48 lines (37 loc) · 1.36 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package nodis
import (
"time"
"github.com/diiyw/nodis/fs"
)
const (
FileSizeKB = 1024
FileSizeMB = 1024 * FileSizeKB
FileSizeGB = 1024 * FileSizeMB
)
// Options represents the configuration options for the database.
type Options struct {
// Path is the path to the database.
Path string
// TidyDuration is the interval which the database is flushing unused keys to disk.
// This is useful for reducing the risk of data loss in the event of a crash.
// It is also used for refreshing hot keys.
TidyDuration time.Duration
// MaxKeyUseTimes is the maximum number of times a key can be used before it is considered hot.
// The default value is 0, which means that the key will never be considered hot.
// Hot keys are refreshed every TidyDuration.
MaxKeyUseTimes uint64
// FileSize is the size of each file. The default value is 1GB.
FileSize int64
// SnapshotDuration is the interval at which the database is snapshot.
// Default 0 for disabling snapshot. and you can call Snapshot manually.
SnapshotDuration time.Duration
// Filesystem is the filesystem to use. The default is the memory filesystem.
Filesystem fs.Fs
// Synchronizer is the synchronizer to use. The default is nil and no synchronization is performed.
Synchronizer Synchronizer
}
var DefaultOptions = &Options{
Path: "data",
FileSize: FileSizeGB,
TidyDuration: 60 * time.Second,
}