private Entry getEntry(String path) { assert path != null; if (cache == null) { return config.vfs().get(path); } CachedEntry e = cache.get(path); if (e != null) { return e; } e = new CachedEntry(config.vfs().get(path), config.maxCacheEntrySizeBytes()); cache.put(path, e); return e; }
HttpFileServiceInvocationHandler(HttpFileServiceConfig config) { this.config = requireNonNull(config, "config"); if (config.maxCacheEntries() != 0) { cache = Collections.synchronizedMap( new LruMap<String, CachedEntry>(config.maxCacheEntries()) { private static final long serialVersionUID = -5517905762044320996L; @Override protected boolean removeEldestEntry(Map.Entry<String, CachedEntry> eldest) { final boolean remove = super.removeEldestEntry(eldest); if (remove) { eldest.getValue().destroyContent(); } return remove; } }); } else { cache = null; } }