@GwtIncompatible public final class CacheBuilderSpec extends Object
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(long, java.util.concurrent.TimeUnit)
.
expireAfterWrite=[duration]
: sets CacheBuilder.expireAfterWrite(long, java.util.concurrent.TimeUnit)
.
refreshAfterWrite=[duration]
: sets CacheBuilder.refreshAfterWrite(long, java.util.concurrent.TimeUnit)
.
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 | Method and Description |
---|---|
static CacheBuilderSpec |
disableCaching()
Returns a CacheBuilderSpec that will prevent caching.
|
boolean |
equals(Object obj) |
int |
hashCode() |
static CacheBuilderSpec |
parse(String cacheBuilderSpecification)
Creates a CacheBuilderSpec from a string.
|
String |
toParsableString()
Returns a string that can be used to parse an equivalent
CacheBuilderSpec . |
String |
toString()
Returns a string representation for this CacheBuilderSpec instance.
|
public static CacheBuilderSpec parse(String cacheBuilderSpecification)
cacheBuilderSpecification
- the string formpublic static CacheBuilderSpec disableCaching()
public String toParsableString()
CacheBuilderSpec
. The order
and form of this representation is not guaranteed, except that reparsing its output will
produce a CacheBuilderSpec
equal to this instance.public String toString()
Copyright © 2010–2017. All rights reserved.