/// <summary> /// Flush all "modified" data blocks in cache onto Disk. /// NOTE: cache fault event will also cause modified data blocks /// to be saved to disk and Save will only save those "modified ones" /// that didn't get evicted from cache during said event. /// </summary> public virtual void Flush() { bool saveIt = false; bool saveDelayed = DelaySaveBlocks; if (IsOpen && IsDirty) { //RegisterChange(); IsDirty = false; if (FileStream != null) { //** save the collection Item(s) in cache SaveState |= SaveTypes.CollectionSave; if (!DelaySaveBlocks) { DelaySaveBlocks = MruManager.Count < 20; } MruManager.Flush(); SaveState ^= SaveTypes.CollectionSave; //** save the collection's meta data WriteToDisk(this, !IsPartOfCollection); saveIt = true; AddToBlocks(DiskBuffer, Blocks); } } if (deletedBlocks != null) { deletedBlocks.Flush(); } if (!saveIt) { return; } DelaySaveBlocks = saveDelayed; SaveBlocks(false); }