When a store
is closed, it just closes the files but items in the buffer are not written to file before closing. So we need an additional Close
function that flushes the buffer before closing the store.
func (s *store) Close() error {
err := s.buffer.Flush()
if err != nil {
return err
}
return s.File.Close()
}