(Java) OpenFeature provider improve the internal cache management.
Until Today the java provider, used the guava cache to store the flags and the segments. Using the guava cache is now discouraged by the guava team.
In order to follow the guidance of the guava team, we have decided to migrate the internal cache of the Java provider from guava
to caffeine
.
This may create a breaking change for you if you were using a custom cache configuration with the guava
cache in your provider.
Because of this, the cache configuration on GoFeatureFlagProviderOptions
that used Guava's CacheBuilder
is now handled by Caffeine
.
How to migrate
Configuration cache with Guava used to be like this:
import com.google.common.cache.CacheBuilder;
// ...
CacheBuilder guavaCacheBuilder = CacheBuilder.newBuilder()
.initialCapacity(100)
.maximumSize(2000);
FeatureProvider provider = new GoFeatureFlagProvider(
GoFeatureFlagProviderOptions
.builder()
.endpoint("https://my-gofeatureflag-instance.org")
.cacheBuilder(guavaCacheBuilder)
.build());
OpenFeatureAPI.getInstance().setProviderAndWait(provider);
// ...
Now with Caffeine it should be like this:
import com.github.benmanes.caffeine.cache.Caffeine;
// ...
Caffeine caffeineCacheConfig = Caffeine.newBuilder()
.initialCapacity(100)
.maximumSize(2000);
FeatureProvider provider = new GoFeatureFlagProvider(
GoFeatureFlagProviderOptions
.builder()
.endpoint("https://my-gofeatureflag-instance.org")
.cacheConfig(caffeineCacheConfig)
.build());
OpenFeatureAPI.getInstance().setProviderAndWait(provider);
// ...
For a complete list of customizations options available in Caffeine, please refer to the Caffeine documentation for more details.