Skip to content

Commit

Permalink
Don't use cache for Qute when the cache is remote
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Sep 8, 2023
1 parent 44a5d6f commit 8ffe29d
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
package io.quarkus.qute.deployment;

import java.util.Optional;

import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.cache.deployment.spi.AdditionalCacheNameBuildItem;
import io.quarkus.deployment.Capabilities;
import io.quarkus.deployment.Capability;
import io.quarkus.cache.deployment.spi.CacheTypeBuildItem;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.qute.cache.QuteCache;

public class CacheProcessor {

@BuildStep
void initialize(Capabilities capabilities, BuildProducer<AdditionalBeanBuildItem> beans,
void initialize(Optional<CacheTypeBuildItem> cacheTypeBuildItem,
BuildProducer<AdditionalBeanBuildItem> beans,
BuildProducer<AdditionalCacheNameBuildItem> cacheNames) {
if (capabilities.isPresent(Capability.CACHE)) {
beans.produce(new AdditionalBeanBuildItem("io.quarkus.qute.runtime.cache.CacheConfigurator"));
// We need to produce additional cache name because quarkus-cache only considers the CombinedIndexBuildItem and not the bean archive index
cacheNames.produce(new AdditionalCacheNameBuildItem(QuteCache.NAME));
if (cacheTypeBuildItem.isEmpty()) { // no caching enabled
return;
}
CacheTypeBuildItem.Type type = cacheTypeBuildItem.get().getType();
if (type != CacheTypeBuildItem.Type.LOCAL) { // it does not make sense to use a remote cache for Qute
return;
}
beans.produce(new AdditionalBeanBuildItem("io.quarkus.qute.runtime.cache.CacheConfigurator"));
// We need to produce additional cache name because quarkus-cache only considers the CombinedIndexBuildItem and not the bean archive index
cacheNames.produce(new AdditionalCacheNameBuildItem(QuteCache.NAME));
}

}

0 comments on commit 8ffe29d

Please sign in to comment.