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]: sets Caffeine#initialCapacity.
maximumSize=[long]: sets Caffeine#maximumSize.
maximumWeight=[long]: sets Caffeine#maximumWeight.
expireAfterAccess=[duration]: sets Caffeine#expireAfterAccess.
expireAfterWrite=[duration]: sets Caffeine#expireAfterWrite.
refreshAfterWrite=[duration]: sets Caffeine#refreshAfterWrite.
weakKeys: sets Caffeine#weakKeys.
weakValues: sets Caffeine#weakValues.
softValues: sets Caffeine#softValues.
recordStats: sets Caffeine#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:
maximumSize and maximumWeight
weakValues and softValues
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).
| Modifier and Type | Field and Description |
|---|---|
| pack-priv @Nullable Duration | |
| pack-priv @Nullable Duration | |
| pack-priv int | |
| pack-priv @Nullable Caffeine. | |
| pack-priv long | |
| pack-priv long | |
| pack-priv boolean | |
| pack-priv @Nullable Duration | |
| pack-priv final String | |
| pack-priv static final String | |
| pack-priv static final String | |
| pack-priv @Nullable Caffeine. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | |
| public boolean | equals(@Nullable Object
the reference object with which to compare. o)Overrides java. |
| pack-priv void | |
| pack-priv void | |
| public int | |
| pack-priv void | |
| pack-priv void | |
| pack-priv void | |
| public static CaffeineSpec | |
| pack-priv static Duration | |
| pack-priv static int | |
| pack-priv static long | |
| pack-priv void | |
| pack-priv static TimeUnit | |
| pack-priv void | |
| pack-priv void | |
| pack-priv Caffeine | |
| public String | Returns: a string representation of this specification that can be parsed into aCaffeineSpecReturns a string representation that can be used to parse an equivalent |
| public String | toString()
Overrides java. CaffeineSpec instance.
|
| pack-priv void | |
| pack-priv void |
| expireAfterAccess | back to summary |
|---|---|
| pack-priv @Nullable Duration expireAfterAccess | |
| expireAfterWrite | back to summary |
|---|---|
| pack-priv @Nullable Duration expireAfterWrite | |
| initialCapacity | back to summary |
|---|---|
| pack-priv int initialCapacity | |
| keyStrength | back to summary |
|---|---|
| pack-priv @Nullable Caffeine. | |
| maximumSize | back to summary |
|---|---|
| pack-priv long maximumSize | |
| maximumWeight | back to summary |
|---|---|
| pack-priv long maximumWeight | |
| recordStats | back to summary |
|---|---|
| pack-priv boolean recordStats | |
| refreshAfterWrite | back to summary |
|---|---|
| pack-priv @Nullable Duration refreshAfterWrite | |
| specification | back to summary |
|---|---|
| pack-priv final String specification | |
| SPLIT_KEY_VALUE | back to summary |
|---|---|
| pack-priv static final String SPLIT_KEY_VALUE | |
| SPLIT_OPTIONS | back to summary |
|---|---|
| pack-priv static final String SPLIT_OPTIONS | |
| valueStrength | back to summary |
|---|---|
| pack-priv @Nullable Caffeine. | |
| CaffeineSpec | back to summary |
|---|---|
| private CaffeineSpec(String specification) | |
| configure | back to summary |
|---|---|
| pack-priv void configure(String key, @Nullable String value) Configures the setting. | |
| equals | back to summary |
|---|---|
| public boolean equals(@Nullable Object o) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| expireAfterAccess | back to summary |
|---|---|
| pack-priv void expireAfterAccess(String key, @Nullable String value) Configures expire after access. | |
| expireAfterWrite | back to summary |
|---|---|
| pack-priv void expireAfterWrite(String key, @Nullable String value) Configures expire after write. | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| initialCapacity | back to summary |
|---|---|
| pack-priv void initialCapacity(String key, @Nullable String value) Configures the initial capacity. | |
| maximumSize | back to summary |
|---|---|
| pack-priv void maximumSize(String key, @Nullable String value) Configures the maximum size. | |
| maximumWeight | back to summary |
|---|---|
| pack-priv void maximumWeight(String key, @Nullable String value) Configures the maximum size. | |
| parse | back to summary |
|---|---|
| public static CaffeineSpec parse(String specification) Creates a CaffeineSpec from a string.
| |
| parseDuration | back to summary |
|---|---|
| pack-priv static Duration parseDuration(String key, @Nullable String value) Returns a parsed duration value. | |
| parseInt | back to summary |
|---|---|
| pack-priv static int parseInt(String key, @Nullable String value) Returns a parsed int value. | |
| parseLong | back to summary |
|---|---|
| pack-priv static long parseLong(String key, @Nullable String value) Returns a parsed long value. | |
| parseOption | back to summary |
|---|---|
| pack-priv void parseOption(String option) Parses and applies the configuration option. | |
| parseTimeUnit | back to summary |
|---|---|
| pack-priv static TimeUnit parseTimeUnit(String key, @Nullable String value) Returns a parsed | |
| recordStats | back to summary |
|---|---|
| pack-priv void recordStats(@Nullable String value) Configures the value as weak or soft references. | |
| refreshAfterWrite | back to summary |
|---|---|
| pack-priv void refreshAfterWrite(String key, @Nullable String value) Configures refresh after write. | |
| toBuilder | back to summary |
|---|---|
| pack-priv Caffeine Returns a | |
| toParsableString | back to summary |
|---|---|
| public String toParsableString() Returns a string representation that can be used to parse an equivalent
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string representation for this
| |
| valueStrength | back to summary |
|---|---|
| pack-priv void valueStrength(String key, @Nullable String value, Caffeine. Configures the value as weak or soft references. | |
| weakKeys | back to summary |
|---|---|
| pack-priv void weakKeys(@Nullable String value) Configures the keys as weak references. | |