CacheBuilder configuration.
CacheBuilderSpec supports parsing configuration off of a string, which makes it
especially useful for command-line configuration of a CacheBuilder.
The string syntax is a series of comma-separated keys or key-value pairs, each corresponding
to a CacheBuilder method.
concurrencyLevel=[integer]: sets CacheBuilder#concurrencyLevel.
initialCapacity=[integer]: sets CacheBuilder#initialCapacity.
maximumSize=[long]: sets CacheBuilder#maximumSize.
maximumWeight=[long]: sets CacheBuilder#maximumWeight.
expireAfterAccess=[duration]: sets CacheBuilder#expireAfterAccess.
expireAfterWrite=[duration]: sets CacheBuilder#expireAfterWrite.
refreshAfterWrite=[duration]: sets CacheBuilder#refreshAfterWrite.
weakKeys: sets CacheBuilder#weakKeys.
softValues: sets CacheBuilder#softValues.
weakValues: sets CacheBuilder#weakValues.
recordStats: sets CacheBuilder#recordStats.
The set of supported keys will grow as CacheBuilder evolves, but existing keys will
never be removed.
Durations are represented by an integer, followed by one of "d", "h", "m", or "s", representing days, hours, minutes, or seconds respectively. (There is currently no syntax to request expiration 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
softValues and weakValues
CacheBuilderSpec does not support configuring CacheBuilder methods with
non-value parameters. These must be configured in code.
A new CacheBuilder can be instantiated from a CacheBuilderSpec using CacheBuilder#from(CacheBuilderSpec) or CacheBuilder#from(String).
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | CacheBuilderSpec.
Parse expireAfterAccess |
| pack-priv static class | CacheBuilderSpec.
Parse concurrencyLevel |
| pack-priv abstract static class | CacheBuilderSpec.
Base class for parsing times with durations |
| pack-priv static class | CacheBuilderSpec.
Parse initialCapacity |
| pack-priv abstract static class | CacheBuilderSpec.
Base class for parsing integers. |
| pack-priv static class | CacheBuilderSpec.
Parse weakKeys |
| pack-priv abstract static class | CacheBuilderSpec.
Base class for parsing integers. |
| pack-priv static class | CacheBuilderSpec.
Parse maximumSize |
| pack-priv static class | CacheBuilderSpec.
Parse maximumWeight |
| pack-priv static class | CacheBuilderSpec.
Parse recordStats |
| pack-priv static class | CacheBuilderSpec.
Parse refreshAfterWrite |
| private static interface | CacheBuilderSpec.
Parses a single value. |
| pack-priv static class | CacheBuilderSpec.
Parse weakValues and softValues |
| pack-priv static class | CacheBuilderSpec.
Parse expireAfterWrite |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv long | |
| pack-priv TimeUnit | |
| pack-priv Integer | |
| pack-priv Integer | |
| private static final Splitter | KEY_VALUE_SPLITTER
Splits the key from the value. |
| private static final Splitter | KEYS_SPLITTER
Splits each key-value pair. |
| pack-priv LocalCache. | |
| pack-priv Long | |
| pack-priv Long | |
| pack-priv Boolean | |
| pack-priv long | |
| pack-priv TimeUnit | |
| private final String | specification
Specification; used for toParseableString(). |
| private static final ImmutableMap | VALUE_PARSERS
Map of names to ValueParser. |
| pack-priv LocalCache. | |
| pack-priv long | |
| pack-priv TimeUnit |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static CacheBuilderSpec | |
| private static Long | durationInNanos(long duration, TimeUnit unit)
Converts an expiration duration/unit pair into a single Long for hashing and equality. |
| public boolean | equals(Object
the reference object with which to compare. obj)Overrides java. |
| private static String | |
| public int | |
| public static CacheBuilderSpec | |
| pack-priv CacheBuilder | |
| public String | |
| public String | toString()
Overrides java. |
| accessExpirationDuration | back to summary |
|---|---|
| pack-priv long accessExpirationDuration
| |
| accessExpirationTimeUnit | back to summary |
|---|---|
| pack-priv TimeUnit accessExpirationTimeUnit
| |
| concurrencyLevel | back to summary |
|---|---|
| pack-priv Integer concurrencyLevel
| |
| initialCapacity | back to summary |
|---|---|
| pack-priv Integer initialCapacity
| |
| KEY_VALUE_SPLITTER | back to summary |
|---|---|
| private static final Splitter KEY_VALUE_SPLITTER Splits the key from the value. | |
| KEYS_SPLITTER | back to summary |
|---|---|
| private static final Splitter KEYS_SPLITTER Splits each key-value pair. | |
| keyStrength | back to summary |
|---|---|
| pack-priv LocalCache. | |
| maximumSize | back to summary |
|---|---|
| pack-priv Long maximumSize
| |
| maximumWeight | back to summary |
|---|---|
| pack-priv Long maximumWeight
| |
| recordStats | back to summary |
|---|---|
| pack-priv Boolean recordStats
| |
| refreshDuration | back to summary |
|---|---|
| pack-priv long refreshDuration
| |
| refreshTimeUnit | back to summary |
|---|---|
| pack-priv TimeUnit refreshTimeUnit
| |
| specification | back to summary |
|---|---|
| private final String specification Specification; used for toParseableString(). | |
| VALUE_PARSERS | back to summary |
|---|---|
| private static final ImmutableMap<String, CacheBuilderSpec. Map of names to ValueParser. | |
| valueStrength | back to summary |
|---|---|
| pack-priv LocalCache. | |
| writeExpirationDuration | back to summary |
|---|---|
| pack-priv long writeExpirationDuration
| |
| writeExpirationTimeUnit | back to summary |
|---|---|
| pack-priv TimeUnit writeExpirationTimeUnit
| |
| CacheBuilderSpec | back to summary |
|---|---|
| private CacheBuilderSpec(String specification) | |
| disableCaching | back to summary |
|---|---|
| public static CacheBuilderSpec disableCaching() Returns a CacheBuilderSpec that will prevent caching. | |
| durationInNanos | back to summary |
|---|---|
| private static Long durationInNanos(long duration, TimeUnit unit) Converts an expiration duration/unit pair into a single Long for hashing and equality. Uses nanos to match CacheBuilder implementation.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) 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. | |
| format | back to summary |
|---|---|
| private static String format(String format, Object... args) | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| parse | back to summary |
|---|---|
| public static CacheBuilderSpec parse(String cacheBuilderSpecification) Creates a CacheBuilderSpec from a string.
| |
| toCacheBuilder | back to summary |
|---|---|
| pack-priv CacheBuilder Returns a CacheBuilder configured according to this instance's specification. | |
| toParsableString | back to summary |
|---|---|
| public String toParsableString() Returns a string that can be used to parse an equivalent | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string representation for this CacheBuilderSpec instance. The form of this representation is not guaranteed.
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| protected void | parseDuration(CacheBuilderSpec spec, long duration, TimeUnit unit)
Implements abstract com. |
| AccessDurationParser | back to summary |
|---|---|
| pack-priv AccessDurationParser() | |
| parseDuration | back to summary |
|---|---|
| protected void parseDuration(CacheBuilderSpec spec, long duration, TimeUnit unit) Implements abstract com.
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| protected void | parseInteger(CacheBuilderSpec spec, int value)
Implements abstract com. |
| ConcurrencyLevelParser | back to summary |
|---|---|
| pack-priv ConcurrencyLevelParser() | |
| parseInteger | back to summary |
|---|---|
| protected void parseInteger(CacheBuilderSpec spec, int value) Implements abstract com.
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | parse(CacheBuilderSpec spec, String key, String value)
Implements com. |
| protected abstract void |
| DurationParser | back to summary |
|---|---|
| pack-priv DurationParser() | |
| parse | back to summary |
|---|---|
| public void parse(CacheBuilderSpec spec, String key, String value) Implements com.
| |
| parseDuration | back to summary |
|---|---|
| protected abstract void parseDuration(CacheBuilderSpec spec, long duration, TimeUnit unit) | |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| protected void | parseInteger(CacheBuilderSpec spec, int value)
Implements abstract com. |
| InitialCapacityParser | back to summary |
|---|---|
| pack-priv InitialCapacityParser() | |
| parseInteger | back to summary |
|---|---|
| protected void parseInteger(CacheBuilderSpec spec, int value) Implements abstract com.
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | parse(CacheBuilderSpec spec, String key, @Nullable String value)
Implements com. |
| protected abstract void |
| IntegerParser | back to summary |
|---|---|
| pack-priv IntegerParser() | |
| parse | back to summary |
|---|---|
| public void parse(CacheBuilderSpec spec, String key, @Nullable String value) Implements com.
| |
| parseInteger | back to summary |
|---|---|
| protected abstract void parseInteger(CacheBuilderSpec spec, int value) | |
| Modifier and Type | Field and Description |
|---|---|
| private final LocalCache. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | parse(CacheBuilderSpec spec, String key, String value)
Implements com. |
| strength | back to summary |
|---|---|
| private final LocalCache. | |
| KeyStrengthParser | back to summary |
|---|---|
| public KeyStrengthParser(LocalCache. | |
| parse | back to summary |
|---|---|
| public void parse(CacheBuilderSpec spec, String key, String value) Implements com.
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | parse(CacheBuilderSpec spec, String key, @Nullable String value)
Implements com. |
| protected abstract void |
| LongParser | back to summary |
|---|---|
| pack-priv LongParser() | |
| parse | back to summary |
|---|---|
| public void parse(CacheBuilderSpec spec, String key, @Nullable String value) Implements com.
| |
| parseLong | back to summary |
|---|---|
| protected abstract void parseLong(CacheBuilderSpec spec, long value) | |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| protected void | parseLong(CacheBuilderSpec spec, long value)
Implements abstract com. |
| MaximumSizeParser | back to summary |
|---|---|
| pack-priv MaximumSizeParser() | |
| parseLong | back to summary |
|---|---|
| protected void parseLong(CacheBuilderSpec spec, long value) Implements abstract com.
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| protected void | parseLong(CacheBuilderSpec spec, long value)
Implements abstract com. |
| MaximumWeightParser | back to summary |
|---|---|
| pack-priv MaximumWeightParser() | |
| parseLong | back to summary |
|---|---|
| protected void parseLong(CacheBuilderSpec spec, long value) Implements abstract com.
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | parse(CacheBuilderSpec spec, String key, String value)
Implements com. |
| RecordStatsParser | back to summary |
|---|---|
| pack-priv RecordStatsParser() | |
| parse | back to summary |
|---|---|
| public void parse(CacheBuilderSpec spec, String key, String value) Implements com.
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| protected void | parseDuration(CacheBuilderSpec spec, long duration, TimeUnit unit)
Implements abstract com. |
| RefreshDurationParser | back to summary |
|---|---|
| pack-priv RefreshDurationParser() | |
| parseDuration | back to summary |
|---|---|
| protected void parseDuration(CacheBuilderSpec spec, long duration, TimeUnit unit) Implements abstract com.
| |
| Modifier and Type | Method and Description |
|---|---|
| public void |
| parse | back to summary |
|---|---|
| public void parse(CacheBuilderSpec spec, String key, String value) | |
| Modifier and Type | Field and Description |
|---|---|
| private final LocalCache. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | parse(CacheBuilderSpec spec, String key, String value)
Implements com. |
| strength | back to summary |
|---|---|
| private final LocalCache. | |
| ValueStrengthParser | back to summary |
|---|---|
| public ValueStrengthParser(LocalCache. | |
| parse | back to summary |
|---|---|
| public void parse(CacheBuilderSpec spec, String key, String value) Implements com.
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| protected void | parseDuration(CacheBuilderSpec spec, long duration, TimeUnit unit)
Implements abstract com. |
| WriteDurationParser | back to summary |
|---|---|
| pack-priv WriteDurationParser() | |
| parseDuration | back to summary |
|---|---|
| protected void parseDuration(CacheBuilderSpec spec, long duration, TimeUnit unit) Implements abstract com.
| |