/// <summary> /// This method must be called before read/write operation to avoid dirty reads. /// It's occurs when my cache contains pages that was changed in another process /// </summary> public bool AvoidDirtyRead() { var cache = (HeaderPage)_cache.GetPage(0); if (cache == null) { return(false); } // read change direct from disk var change = _disk.GetChangeID(); // if changeID was changed, file was changed by another process - clear all cache if (cache.ChangeID != change) { _cache.Clear(); return(true); } return(false); }