Specifies the maximum weight of entries the cache may contain. Weight is determined using the
Weigher specified with
#weigher, and use of this method requires a
corresponding call to
#weigher prior to calling
#build.
Note that the cache may evict an entry before this limit is exceeded. As the cache
size grows close to the maximum, the cache evicts entries that are less likely to be used
again. For example, the cache may evict an entry because it hasn't been used recently or very
often.
When
weight is zero, elements will be evicted immediately after being loaded into
cache. This can be useful in testing, or to disable caching temporarily without a code
change.
Note that weight is only used to determine whether the cache is over capacity; it has no
effect on selecting which entry should be evicted next.
This feature cannot be used in conjunction with
#maximumSize.