/// <summary>Modify the configuration of the window cache.</summary> /// <remarks> /// Modify the configuration of the window cache. /// <p> /// The new configuration is applied immediately. If the new limits are /// smaller than what what is currently cached, older entries will be purged /// as soon as possible to allow the cache to meet the new limit. /// </remarks> /// <param name="cfg">the new window cache configuration.</param> /// <exception cref="System.ArgumentException"> /// the cache configuration contains one or more invalid /// settings, usually too low of a limit. /// </exception> public static void Reconfigure(WindowCacheConfig cfg) { NGit.Storage.File.WindowCache nc = new NGit.Storage.File.WindowCache(cfg); NGit.Storage.File.WindowCache oc = cache; if (oc != null) { oc.RemoveAll(); } cache = nc; streamFileThreshold = cfg.GetStreamFileThreshold(); DeltaBaseCache.Reconfigure(cfg); }
/// <exception cref="System.IO.IOException"></exception> internal static ByteWindow Get(PackFile pack, long offset) { NGit.Storage.File.WindowCache c = cache; ByteWindow r = c.GetOrLoad(pack, c.ToStart(offset)); if (c != cache) { // The cache was reconfigured while we were using the old one // to load this window. The window is still valid, but our // cache may think its still live. Ensure the window is removed // from the old cache so resources can be released. // c.RemoveAll(); } return(r); }