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 String
CLEAR
public final static String
USE_EXPIRES
public final static String
MAX_SIZE
public transient boolean
useExpires
public final static String
USERNAME
public final static String
PASSWORD
public transient JMeterContext
threadContext
public transient String
threadName
public final static TestElement.Companion
Companion
public final static String
NAME
public final static String
GUI_CLASS
public final static String
ENABLED
public final static String
TEST_CLASS
public final static String
COMMENTS
-
Constructor Summary
Constructors Constructor Description CacheManager()
-
Method Summary
Modifier and Type Method Description boolean
getUseExpires()
void
setUseExpires(boolean expires)
boolean
getControlledByThread()
void
setControlledByThread(boolean control)
void
saveDetails(URLConnection conn, HTTPSampleResult res)
Save the Last-Modified, Etag, and Expires headers if the result is cacheable. void
saveDetails(HttpResponse method, HTTPSampleResult res)
Save the Last-Modified, Etag, and Expires headers if the result is cacheable. void
setHeaders(URL url, HttpRequestBase request)
Check the cache, and if there is a match, set the headers: - If-Modified-Since
- If-None-Match
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
boolean
inCache(URL url)
Check the cache, if the entry has an expires header and the entry has not expired, return true
boolean
inCache(URL url, Array<Header> allHeaders)
boolean
inCache(URL url, Array<Header> allHeaders)
boolean
getClearEachIteration()
void
setClearEachIteration(boolean clear)
int
getMaxSize()
void
setMaxSize(int size)
void
clear()
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 void
testStarted()
void
testEnded()
void
testStarted(String host)
void
testEnded(String host)
void
testIterationStart(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)
-
-
-