MCPcopy Index your code
hub / github.com/HtmlUnit/htmlunit / cacheIfPossible

Method cacheIfPossible

src/main/java/org/htmlunit/Cache.java:175–189  ·  view source on GitHub ↗

Caches the specified object, if the corresponding request and response objects indicate that it is cacheable. @param request the request corresponding to the specified compiled script @param response the response corresponding to the specified compiled script @param toCache the object that is to be

(final WebRequest request, final WebResponse response, final Object toCache)

Source from the content-addressed store, hash-verified

173 * @return whether the response was cached or not
174 */
175 public boolean cacheIfPossible(final WebRequest request, final WebResponse response, final Object toCache) {
176 if (isCacheable(request, response)) {
177 final URL url = request.getUrl();
178 if (url == null) {
179 return false;
180 }
181
182 final Entry entry = new Entry(UrlUtils.normalize(url), response, toCache);
183 entries_.put(entry.key_, entry);
184 deleteOverflow();
185 return true;
186 }
187
188 return false;
189 }
190
191 /**
192 * Caches the parsed version of the specified CSS snippet. We key the cache based on CSS snippets (rather

Callers 8

cleanUpOverflowMethod · 0.95
cleanUpOnClearMethod · 0.95
loadJavaScriptFromUrlMethod · 0.95
loadStylesheetMethod · 0.95

Calls 5

isCacheableMethod · 0.95
normalizeMethod · 0.95
deleteOverflowMethod · 0.95
getUrlMethod · 0.65
putMethod · 0.45

Tested by 3

cleanUpOverflowMethod · 0.76
cleanUpOnClearMethod · 0.76