public static Caffeine newCacheBuilder(final SimpleCacheProperties cache) {
        val builder = Caffeine.newBuilder()
            .initialCapacity(cache.getInitialCapacity())
            .maximumSize(cache.getCacheSize());
        if (cache instanceof final ExpiringSimpleCacheProperties expiring) {
            builder.expireAfterWrite(newDuration(expiring.getDuration()));
        }
        builder.removalListener((key, value, cause) -> {
            LOGGER.trace("Removing cached value [{}] linked to cache key [{}]; removal cause is [{}]", value, key, cause);
            Unchecked.consumer(__ -> {
                if (value instanceof final AutoCloseable closeable) {
                    Objects.requireNonNull(closeable).close();
                }
            }).accept(value);
        });
        return builder;
    }
New cache builder.

@param cache the cache
@return the caffeine
api/cas-server-core-api-configuration-model/src/main/java/org/apereo/cas/configuration/support/Beans.java