Class ModelCache

java.lang.Object
se.diabol.jenkins.pipeline.cache.ModelCache

@Extension public class ModelCache extends Object
Remembers computed view models for a short while, so that many browsers polling the same view do not each walk the build history. An entry remembers the jobs its model shows: when a build of one of them starts, ends or is deleted, or one of them enters or leaves the queue, only the entries showing that job are dropped, so that a busy controller does not recompute every board on every event. A job being created, reconfigured, renamed or deleted empties the cache, because that can change which jobs belong to which pipeline. A model that contains a running or queued build expires quickly on its own as well, because stages of a Pipeline run come and go without any of those events.

Two system properties tune how long an entry may be served, in seconds, and are read on every request so that they can be changed at runtime as well as set at startup:

  • se.diabol.jenkins.pipeline.cache.ModelCache.idleSeconds (default 30) for a model in which nothing is running or queued;
  • se.diabol.jenkins.pipeline.cache.ModelCache.activeSeconds (default 2) for a model with a running or queued build, which bounds how stale a progress bar or a Pipeline stage can be.
Zero turns the cache off.
  • Constructor Details

    • ModelCache

      public ModelCache()
  • Method Details

    • get

      public static ModelCache get()
    • get

      public List<Component> get(String key, Supplier<List<Component>> loader)
      The cached model for the key, or the loader's result which is then cached.
    • cached

      public ModelCache.Cached cached(String key, Supplier<List<Component>> loader)
      The cached model for the key with its version and exported forms, or the loader's result which is then cached.
    • clear

      public void clear()
    • invalidate

      public void invalidate(String jobFullName)
      Drops the models that show the job, or something inside it such as a matrix configuration or a promotion.