Class CacheManager
-
- All Implemented Interfaces:
-
java.io.Serializable,java.lang.Cloneable,org.apache.jmeter.config.ConfigElement,org.apache.jmeter.gui.Searchable,org.apache.jmeter.testelement.TestElement,org.apache.jmeter.testelement.TestIterationListener,org.apache.jmeter.testelement.TestStateListener
public class CacheManager extends ConfigTestElement implements TestStateListener, TestIterationListener, Serializable
Handles HTTP Caching.
-
-
Field Summary
Fields Modifier and Type Field Description public final static StringCLEARpublic final static StringUSE_EXPIRESpublic final static StringMAX_SIZEpublic transient booleanuseExpirespublic final static StringUSERNAMEpublic final static StringPASSWORDpublic transient JMeterContextthreadContextpublic transient StringthreadNamepublic final static TestElement.CompanionCompanionpublic final static StringNAMEpublic final static StringGUI_CLASSpublic final static StringENABLEDpublic final static StringTEST_CLASSpublic final static StringCOMMENTS
-
Constructor Summary
Constructors Constructor Description CacheManager()
-
Method Summary
Modifier and Type Method Description booleangetUseExpires()voidsetUseExpires(boolean expires)booleangetControlledByThread()voidsetControlledByThread(boolean control)voidsaveDetails(URLConnection conn, HTTPSampleResult res)Save the Last-Modified, Etag, and Expires headers if the result is cacheable. voidsaveDetails(HttpResponse method, HTTPSampleResult res)Save the Last-Modified, Etag, and Expires headers if the result is cacheable. voidsetHeaders(URL url, HttpRequestBase request)Check the cache, and if there is a match, set the headers: - If-Modified-Since
- If-None-Match
voidsetHeaders(HttpURLConnection conn, Array<Header> headers, URL url)Check the cache, and if there is a match, set the headers: - If-Modified-Since
- If-None-Match
booleaninCache(URL url)Check the cache, if the entry has an expires header and the entry has not expired, return truebooleaninCache(URL url, Array<Header> allHeaders)booleaninCache(URL url, Array<Header> allHeaders)booleangetClearEachIteration()voidsetClearEachIteration(boolean clear)intgetMaxSize()voidsetMaxSize(int size)voidclear()CacheManagercreateCacheManagerProxy()create a cache manager that share the underlying cache of the current one it allows to use the same cache in different threads which does not inherit from each other voidtestStarted()voidtestEnded()voidtestStarted(String host)voidtestEnded(String host)voidtestIterationStart(LoopIterationEvent event)-
Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement
canRemove, clearTestElementChildren, clone, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, getPropertyOrNull, getSearchableTokens, getThreadContext, getThreadName, hashCode, isEnabled, isRunningVersion, isTemporary, propertyIterator, recoverRunningVersion, removeProperty, setComment, setEnabled, setName, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse -
Methods inherited from class org.apache.jmeter.config.ConfigTestElement
addConfigElement, addTestElement, expectsModification, getProps, getSchema -
Methods inherited from class org.apache.jmeter.testelement.TestElement
get, get, get, get, get, get, get, get, get, getOrCreate, getOrCreate, getOrNull, getOrNull, getOrNull, getProps, getSchema, getString, removed, set -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getUseExpires
boolean getUseExpires()
-
setUseExpires
void setUseExpires(boolean expires)
-
getControlledByThread
boolean getControlledByThread()
-
setControlledByThread
void setControlledByThread(boolean control)
-
saveDetails
void saveDetails(URLConnection conn, HTTPSampleResult res)
Save the Last-Modified, Etag, and Expires headers if the result is cacheable. Version for Java implementation.
- Parameters:
conn- connectionres- result
-
saveDetails
void saveDetails(HttpResponse method, HTTPSampleResult res)
Save the Last-Modified, Etag, and Expires headers if the result is cacheable. Version for Apache HttpClient implementation.
- Parameters:
method- HttpResponse to extract header information fromres- result to decide if result is cacheable
-
setHeaders
void setHeaders(URL url, HttpRequestBase request)
Check the cache, and if there is a match, set the headers:
- If-Modified-Since
- If-None-Match
- Parameters:
url- URL to look up in cacherequest- where to set the headers
-
setHeaders
void setHeaders(HttpURLConnection conn, Array<Header> headers, URL url)
Check the cache, and if there is a match, set the headers:
- If-Modified-Since
- If-None-Match
- Parameters:
conn- where to set the headersheaders- Array of org.apache.jmeter.protocol.http.control.Headerurl- URL to look up in cache
-
inCache
@Deprecated() boolean inCache(URL url)
Check the cache, if the entry has an expires header and the entry has not expired, return
true- Parameters:
url- URL to look up in cache
-
getClearEachIteration
boolean getClearEachIteration()
-
setClearEachIteration
void setClearEachIteration(boolean clear)
-
getMaxSize
int getMaxSize()
-
setMaxSize
void setMaxSize(int size)
- Parameters:
size- int cache max size
-
clear
void clear()
-
createCacheManagerProxy
CacheManager createCacheManagerProxy()
create a cache manager that share the underlying cache of the current one it allows to use the same cache in different threads which does not inherit from each other
-
testStarted
void testStarted()
-
testEnded
void testEnded()
-
testStarted
void testStarted(String host)
-
testIterationStart
void testIterationStart(LoopIterationEvent event)
-
-
-