Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2016 Ben Manes. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.benmanes.caffeine.cache;
import static com.github.benmanes.caffeine.cache.Caffeine.UNSET_INT;
import static com.github.benmanes.caffeine.cache.Caffeine.requireArgument;
import static com.github.benmanes.caffeine.cache.Caffeine.requireState;
import static java.util.Objects.requireNonNull;
import java.time.Duration;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import com.github.benmanes.caffeine.cache.Caffeine.Strength;
/**
* A specification of a {@link Caffeine} builder configuration.
*
* {@code CaffeineSpec} supports parsing configuration off of a string, which makes it especially
* useful for command-line configuration of a {@code Caffeine} builder.
*
* The string syntax is a series of comma-separated keys or key-value pairs, each corresponding to a
* {@code Caffeine} builder method.
*
* Durations are represented as either an ISO-8601 string using {@link Duration#parse(CharSequence)}
* or by an integer followed by one of "d", "h", "m", or "s", representing days, hours, minutes, or
* seconds respectively. There is currently no short syntax to request durations 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:
*
*
{@code maximumSize} and {@code maximumWeight}
*
{@code weakValues} and {@code softValues}
*
*
* {@code CaffeineSpec} does not support configuring {@code Caffeine} methods with non-value
* parameters. These must be configured in code.
*
* A new {@code Caffeine} builder can be instantiated from a {@code CaffeineSpec} using
* {@link Caffeine#from(CaffeineSpec)} or {@link Caffeine#from(String)}.
*
* @author [email protected] (Ben Manes)
*/
public final class CaffeineSpec {
static final String SPLIT_OPTIONS = ",";
static final String SPLIT_KEY_VALUE = "=";
final String specification;
int initialCapacity = UNSET_INT;
long maximumWeight = UNSET_INT;
long maximumSize = UNSET_INT;
boolean recordStats;
@Nullable Strength keyStrength;
@Nullable Strength valueStrength;
@Nullable Duration expireAfterWrite;
@Nullable Duration expireAfterAccess;
@Nullable Duration refreshAfterWrite;
private CaffeineSpec(String specification) {
this.specification = requireNonNull(specification);
}
/**
* Returns a {@link Caffeine} builder configured according to this specification.
*
* @return a builder configured to the specification
*/
Caffeine