Specifies the maximum number of entries the cache may contain. <p>Note that the cache <b>may evict an entry before this limit is exceeded</b>. For example, in the current implementation, when {@code concurrencyLevel} is greater than {@code 1}, each resulting segment inside the cache <i>independentl
(long maximumSize)
| 493 | * @throws IllegalStateException if a maximum size or weight was already set |
| 494 | */ |
| 495 | @CanIgnoreReturnValue |
| 496 | public CacheBuilder<K, V> maximumSize(long maximumSize) { |
| 497 | checkState( |
| 498 | this.maximumSize == UNSET_INT, "maximum size was already set to %s", this.maximumSize); |
| 499 | checkState( |
| 500 | this.maximumWeight == UNSET_INT, |
| 501 | "maximum weight was already set to %s", |
| 502 | this.maximumWeight); |
| 503 | checkState(this.weigher == null, "maximum size can not be combined with weigher"); |
| 504 | checkArgument(maximumSize >= 0, "maximum size must not be negative"); |
| 505 | this.maximumSize = maximumSize; |
| 506 | return this; |
| 507 | } |
| 508 | |
| 509 | /** |
| 510 | * Specifies the maximum weight of entries the cache may contain. Weight is determined using the |