Specifies the maximum number of entries the cache may contain. 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
(long size)
| 417 | |
| 418 | |
| 419 | public CacheBuilder<K, V> maximumSize(long size) { |
| 420 | checkState(this.maximumSize == UNSET_INT, "maximum size was already set to %s", this.maximumSize); |
| 421 | checkState(this.maximumWeight == UNSET_INT, "maximum weight was already set to %s", this.maximumWeight); |
| 422 | checkState(this.weigher == null, "maximum size can not be combined with weigher"); |
| 423 | checkArgument(size >= 0, "maximum size must not be negative"); |
| 424 | this.maximumSize = size; |
| 425 | return this; |
| 426 | } |
| 427 | |
| 428 | /** |
| 429 | * Specifies the maximum weight of entries the cache may contain. Weight is determined using the |
no test coverage detected