Esempio n. 1
0
 /**
  * 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.
  *
  * @param cfg the new window cache configuration.
  * @throws IllegalArgumentException the cache configuration contains one or more invalid settings,
  *     usually too low of a limit.
  */
 public static void reconfigure(final WindowCacheConfig cfg) {
   final WindowCache nc = new WindowCache(cfg);
   final WindowCache oc = cache;
   if (oc != null) oc.removeAll();
   cache = nc;
   UnpackedObjectCache.reconfigure(cfg);
 }
Esempio n. 2
0
 static final ByteWindow get(final PackFile pack, final long offset) throws IOException {
   final WindowCache c = cache;
   final 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;
 }
Esempio n. 3
0
 static final void purge(final PackFile pack) {
   cache.removeAll(pack);
 }