示例#1
0
 void PersistInFile(string key, byte[] buffer, long commit)
 {
     StorageFramesEvil.WriteFrame(key, commit, buffer, _currentWriter);
     // make sure that we persist
     // NB: this is not guaranteed to work on Linux
     _currentWriter.Flush(true);
 }
示例#2
0
        IEnumerable <StorageFrameDecoded> EnumerateHistory()
        {
            // cleanup old pending files
            // load indexes
            // build and save missing indexes
            var datFiles = _info.EnumerateFiles("*.dat");

            foreach (var fileInfo in datFiles.OrderBy(fi => fi.Name))
            {
                // quick cleanup
                if (fileInfo.Length == 0)
                {
                    fileInfo.Delete();
                    continue;
                }

                using (var reader = fileInfo.OpenRead())
                {
                    StorageFrameDecoded result;
                    while (StorageFramesEvil.TryReadFrame(reader, out result))
                    {
                        yield return(result);
                    }
                }
            }
        }