Caffeine builder configuration.
CaffeineSpec supports parsing configuration from a string, which makes it especially
useful for command-line configuration of a Caffeine builder.
The string syntax is a series of comma-separated keys or key-value pairs, each corresponding to a
Caffeine builder method.
initialCapacity=[integer]: setsCaffeine.initialCapacity.maximumSize=[long]: setsCaffeine.maximumSize.maximumWeight=[long]: setsCaffeine.maximumWeight.expireAfterAccess=[duration]: setsCaffeine.expireAfterAccess(java.time.Duration).expireAfterWrite=[duration]: setsCaffeine.expireAfterWrite(java.time.Duration).refreshAfterWrite=[duration]: setsCaffeine.refreshAfterWrite(java.time.Duration).weakKeys: setsCaffeine.weakKeys().weakValues: setsCaffeine.weakValues().softValues: setsCaffeine.softValues().recordStats: setsCaffeine.recordStats().
Durations are represented as either an ISO-8601 string using Duration.parse(CharSequence)
or by an integer followed by one of "d", "h", "m", or "s", representing days, hours, minutes, or
seconds, respectively. There is currently no short syntax to request durations in milliseconds,
microseconds, or nanoseconds.
Whitespace before and after commas and equal signs is ignored. Keys may not be repeated; it is also illegal to use the following pairs of keys in a single value:
maximumSizeandmaximumWeightweakValuesandsoftValues
CaffeineSpec does not support configuring Caffeine methods with non-value
parameters. These must be configured in code.
A new Caffeine builder can be instantiated from a CaffeineSpec using
Caffeine.from(CaffeineSpec) or Caffeine.from(String).
-
Method Summary
Modifier and TypeMethodDescriptionbooleaninthashCode()static CaffeineSpecCreates a CaffeineSpec from a string.Returns a string representation that can be used to parse an equivalentCaffeineSpec.toString()Returns a string representation for thisCaffeineSpecinstance.
-
Method Details
-
parse
Creates a CaffeineSpec from a string.- Parameters:
specification- the string form- Returns:
- the parsed specification
-
equals
-
hashCode
public int hashCode() -
toParsableString
Returns a string representation that can be used to parse an equivalentCaffeineSpec. The order and form of this representation is not guaranteed, except that parsing its output will produce aCaffeineSpecequal to this instance.- Returns:
- a string representation of this specification that can be parsed into a
CaffeineSpec
-
toString
Returns a string representation for thisCaffeineSpecinstance. The form of this representation is not guaranteed.
-