Class CaffeineBoundedItemStores
java.lang.Object
io.javaoperatorsdk.operator.processing.event.source.cache.CaffeineBoundedItemStores
A factory for Caffeine-backed
BoundedItemStore. The implementation uses a CaffeineBoundedCache to store
resources and progressively evict them if they haven't been used in a while. The idea about
CaffeinBoundedItemStore-s is that, caffeine will cache the resources which were recently used,
and will evict resource, which are not used for a while. This is ideal for startup performance
and efficiency when all resources should be cached to avoid undue load on the API server. This is
why setting a maximal cache size is not practical and the approach of evicting least recently
used resources was chosen. However, depending on controller implementations and domains, it could
happen that some / many of these resources are then seldom or even reconciled anymore. In that
situation, large amounts of memory might be consumed to cache resources that are never used
again.
Note that if a resource is reconciled and is not present anymore in cache, it will transparently be fetched again from the API server. Similarly, since associated secondary resources are usually reconciled too, they might need to be fetched and populated to the cache, and will remain there for some time, for subsequent reconciliations.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <R extends io.fabric8.kubernetes.api.model.HasMetadata>
BoundedItemStore<R>boundedItemStore(io.fabric8.kubernetes.client.KubernetesClient client, Class<R> rClass, com.github.benmanes.caffeine.cache.Cache<String, R> cache) static <R extends io.fabric8.kubernetes.api.model.HasMetadata>
BoundedItemStore<R>boundedItemStore(io.fabric8.kubernetes.client.KubernetesClient client, Class<R> rClass, Duration accessExpireDuration)
-
Method Details
-
boundedItemStore
public static <R extends io.fabric8.kubernetes.api.model.HasMetadata> BoundedItemStore<R> boundedItemStore(io.fabric8.kubernetes.client.KubernetesClient client, Class<R> rClass, Duration accessExpireDuration) - Type Parameters:
R- resource type- Parameters:
client- Kubernetes ClientrClass- resource classaccessExpireDuration- the duration after resources is evicted from cache if not accessed.- Returns:
- the ItemStore implementation
-
boundedItemStore
public static <R extends io.fabric8.kubernetes.api.model.HasMetadata> BoundedItemStore<R> boundedItemStore(io.fabric8.kubernetes.client.KubernetesClient client, Class<R> rClass, com.github.benmanes.caffeine.cache.Cache<String, R> cache)
-