- java.lang.Object
-
- com.github.benmanes.caffeine.cache.CaffeineSpec
-
public final class CaffeineSpec extends Object
A specification of aCaffeinebuilder configuration.CaffeineSpecsupports parsing configuration off of a string, which makes it especially useful for command-line configuration of aCaffeinebuilder.The string syntax is a series of comma-separated keys or key-value pairs, each corresponding to a
Caffeinebuilder 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
CaffeineSpecdoes not support configuringCaffeinemethods with non-value parameters. These must be configured in code.A new
Caffeinebuilder can be instantiated from aCaffeineSpecusingCaffeine.from(CaffeineSpec)orCaffeine.from(String).
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(@Nullable Object o)inthashCode()static CaffeineSpecparse(String specification)Creates a CaffeineSpec from a string.StringtoParsableString()Returns a string that can be used to parse an equivalentCaffeineSpec.StringtoString()Returns a string representation for thisCaffeineSpecinstance.
-
-
-
Method Detail
-
parse
public static CaffeineSpec parse(String specification)
Creates a CaffeineSpec from a string.- Parameters:
specification- the string form- Returns:
- the parsed specification
-
toParsableString
public String toParsableString()
Returns a string 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
-
-