Class CacheManager

All Implemented Interfaces:
Serializable, Cloneable, ConfigElement, Searchable, TestElement, TestIterationListener, TestStateListener

public class CacheManager extends ConfigTestElement implements TestStateListener, TestIterationListener, Serializable
Handles HTTP Caching.
See Also:
  • Field Details

  • Constructor Details

    • CacheManager

      public CacheManager()
  • Method Details

    • getControlledByThread

      public boolean getControlledByThread()
    • setControlledByThread

      public void setControlledByThread(boolean control)
    • saveDetails

      public 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 - connection
      res - result
    • saveDetails

      public void saveDetails(org.apache.http.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 from
      res - result to decide if result is cacheable
    • setHeaders

      public void setHeaders(URL url, org.apache.http.client.methods.HttpRequestBase request)
      Check the cache, and if there is a match, set the headers:
      • If-Modified-Since
      • If-None-Match
      Apache HttpClient version.
      Parameters:
      url - URL to look up in cache
      request - where to set the headers
    • setHeaders

      public void setHeaders(HttpURLConnection conn, Header[] headers, URL url)
      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 cache
      headers - Array of Header
      conn - where to set the headers
    • inCache

      @Deprecated public 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
      Returns:
      true if entry has an expires header and the entry has not expired, else false
    • inCache

      public boolean inCache(URL url, org.apache.http.Header[] allHeaders)
    • inCache

      public boolean inCache(URL url, Header[] allHeaders)
    • getClearEachIteration

      public boolean getClearEachIteration()
    • setClearEachIteration

      public void setClearEachIteration(boolean clear)
    • getUseExpires

      public boolean getUseExpires()
    • setUseExpires

      public void setUseExpires(boolean expires)
    • getMaxSize

      public int getMaxSize()
      Returns:
      int cache max size
    • setMaxSize

      public void setMaxSize(int size)
      Parameters:
      size - int cache max size
    • clear

      public void clear()
      Description copied from class: AbstractTestElement
      Clear the TestElement of all data.
      Specified by:
      clear in interface TestElement
      Overrides:
      clear in class AbstractTestElement
    • createCacheManagerProxy

      public 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
      Returns:
      a cache manager that share the underlying cache of the current one
      Since:
      3.0
    • testStarted

      public void testStarted()
      Description copied from interface: TestStateListener

      Called just before the start of the test from the main engine thread. This is before the test elements are cloned. Note that not all the test variables will have been set up at this point.

      N.B. testStarted() and testEnded() are called from different threads.

      Specified by:
      testStarted in interface TestStateListener
      See Also:
    • testEnded

      public void testEnded()
      Description copied from interface: TestStateListener

      Called once for all threads after the end of a test. This will use the same element instances as at the start of the test.

      N.B. testStarted() and testEnded() are called from different threads.

      Specified by:
      testEnded in interface TestStateListener
      See Also:
    • testStarted

      public void testStarted(String host)
      Description copied from interface: TestStateListener

      Called just before the start of the test from the main engine thread. This is before the test elements are cloned. Note that not all the test variables will have been set up at this point.

      N.B. testStarted() and testEnded() are called from different threads.

      Specified by:
      testStarted in interface TestStateListener
      Parameters:
      host - name of host
      See Also:
    • testEnded

      public void testEnded(String host)
      Description copied from interface: TestStateListener

      Called once for all threads after the end of a test. This will use the same element instances as at the start of the test.

      N.B. testStarted() and testEnded() are called from different threads.

      Specified by:
      testEnded in interface TestStateListener
      Parameters:
      host - name of host
      See Also:
    • testIterationStart

      public void testIterationStart(LoopIterationEvent event)
      Description copied from interface: TestIterationListener
      Each time through a Thread Group's test script, an iteration event is fired for each thread. This will be after the test elements have been cloned, so in general the instance will not be the same as the ones the start/end methods call.
      Specified by:
      testIterationStart in interface TestIterationListener
      Parameters:
      event - the iteration event