Class KeyBase

java.lang.Object
org.frontcache.warmer.KeyBase

public final class KeyBase extends Object
The scheme://host[:port] a warm run's cache keys are built on.

Why it is a run parameter and not something each list entry decides

FrontCacheEngine.getCurrentRequestURL2Context builds the key from the connection's scheme, the Host header and the port - so a list entry does not decide its own key, the loopback request's Host header does. Get the host wrong and the run succeeds, reports every entry stored, and visitors miss on all of them, with nothing in any log to say so. The sources of a list also disagree: a dump-keys file holds real keys, a sitemap holds https:// public URLs where the key says http://, a hand-written list holds paths. So the warmer uses only the path and query of an entry and takes this base from the run. See docs/cache-warmer-proposal.md section 5. Normalized the way the key is: lowercase scheme and host, and the default port for the scheme dropped, since getCurrentRequestURL2Context drops it too.
  • Method Details

    • parse

      public static KeyBase parse(String value)
      Parameters:
      value - http(s)://host[:port], optionally with a trailing /
      Throws:
      IllegalArgumentException - with a message fit for an operator, when it is not one
    • parseOrNull

      public static KeyBase parseOrNull(String value)
      Same as parse(String), or null instead of an exception.
    • getScheme

      public String getScheme()
    • isSecure

      public boolean isSecure()
    • hostHeader

      public String hostHeader()
      What the loopback request sends as Host: host[:port].
    • keyFor

      public String keyFor(String pathAndQuery)
      The key an entry is stored under.
    • isBaseOf

      public boolean isBaseOf(String key)
      Is key a key under this base? Compared as a prefix - the path is not this class's business.
    • baseOf

      public static String baseOf(String key)
      scheme://host[:port] of a key, normalized like a key base; null when it has none.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object