NeverSyncPolicy=iota// The policy 'Never' means fsync is never called, the Operating System will be in charge of your data. This is the fastest and less safe method.
EverySecondSyncPolicy=iota// The policy 'EverySecond' means that fsync will be called every second or so. This is fast enough, and at most you can lose one second of data if there is a disaster.
AlwaysSyncPolicy=iota// The policy 'Always' means fsync is called after every write. This is super duper safe and very incredibly slow.
)
// String returns a string respesentation.
func(policySyncPolicy)String()string{
switchpolicy{
default:
return"unknown"
caseNever:
return"never"
caseEverySecond:
return"every second"
caseAlways:
return"always"
}
}
varerrClosed=errors.New("closed")
// AOF represents an open file descriptor.
typeAOFstruct{
musync.Mutex
f*os.File
closedbool
rd*Reader
policySyncPolicy
atEndbool
}
// OpenAOF will open and return an AOF file. If the file does not exist a new one will be created.
// The policy 'EverySecond' means that fsync will be called every second or so. This is fast enough, and at most you can lose one second of data if there is a disaster.
// The policy 'Never' means fsync is never called, the Operating System will be in charge of your data. This is the fastest and less safe method.
// The policy 'Always' means fsync is called after every write. This is super duper safe and very incredibly slow.