forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't use cache for Qute when the cache is remote
Closes: quarkusio#35680
- Loading branch information
Showing
1 changed file
with
14 additions
and
7 deletions.
There are no files selected for viewing
21 changes: 14 additions & 7 deletions
21
extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/CacheProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
|
||
} |