Class ValueCache

java.lang.Object
io.jenkins.plugins.restlistparam.ValueCache

public final class ValueCache extends Object
The processed entries of successful fetches (all pages, after extraction, filter and order), kept in memory for each parameter's cache time, whatever caching headers the endpoint sent.

Entries are kept per job, parameter name and value-source configuration, so jobs with different credentials never share entries and a changed configuration makes earlier entries unreachable. The number of cached parameters is bounded; the least recently used one is evicted first. Nothing is written to disk.

  • Field Details

  • Method Details

    • get

      public static ValueCache get()
    • clearOnStartup

      @Initializer(after=PLUGINS_STARTED) public static void clearOnStartup()
      Starts every Jenkins instance with an empty cache, also when one JVM runs several instances one after another.
    • getFresh

      public List<ValueItem> getFresh(ValueCache.Key key, int cacheTimeMinutes)
      Parameters:
      key - The parameter's key
      cacheTimeMinutes - The parameter's cache time; 0 or less means nothing is fresh
      Returns:
      The cached entries if they were fetched less than cacheTimeMinutes ago, otherwise null
    • put

      public void put(ValueCache.Key key, List<ValueItem> values)
      Stores the entries of a successful fetch, fetched now, replacing earlier entries of the same key.
    • clear

      public void clear()
      Removes the entries of all parameters.
    • size

      public int size()
      Returns:
      How many parameters have entries cached, fresh or not
    • keyFor

      public static ValueCache.Key keyFor(AbstractRestListParameterDefinition definition, Item context)
      Parameters:
      definition - The parameter
      context - The job the entries are fetched for, or null outside any job
      Returns:
      The key of definition's entries in context