Enable simple-cache for local-cache

Closes #20486
This commit is contained in:
Pedro Ruivo 2023-05-22 10:53:34 +01:00 committed by Michal Hajas
parent 2252b09949
commit abd75a786f
3 changed files with 11 additions and 4 deletions

View file

@ -238,6 +238,7 @@ public class DefaultInfinispanConnectionProviderFactory implements InfinispanCon
ConfigurationBuilder sessionConfigBuilder = createCacheConfigurationBuilder(); ConfigurationBuilder sessionConfigBuilder = createCacheConfigurationBuilder();
if (clustered) { if (clustered) {
sessionConfigBuilder.simpleCache(false);
String sessionsMode = config.get("sessionsMode", "distributed"); String sessionsMode = config.get("sessionsMode", "distributed");
if (sessionsMode.equalsIgnoreCase("replicated")) { if (sessionsMode.equalsIgnoreCase("replicated")) {
sessionConfigBuilder.clustering().cacheMode(async ? CacheMode.REPL_ASYNC : CacheMode.REPL_SYNC); sessionConfigBuilder.clustering().cacheMode(async ? CacheMode.REPL_ASYNC : CacheMode.REPL_SYNC);
@ -320,6 +321,7 @@ public class DefaultInfinispanConnectionProviderFactory implements InfinispanCon
ConfigurationBuilder replicationConfigBuilder = createCacheConfigurationBuilder(); ConfigurationBuilder replicationConfigBuilder = createCacheConfigurationBuilder();
if (clustered) { if (clustered) {
replicationConfigBuilder.simpleCache(false);
replicationConfigBuilder.clustering().cacheMode(async ? CacheMode.REPL_ASYNC : CacheMode.REPL_SYNC); replicationConfigBuilder.clustering().cacheMode(async ? CacheMode.REPL_ASYNC : CacheMode.REPL_SYNC);
} }
@ -355,6 +357,7 @@ public class DefaultInfinispanConnectionProviderFactory implements InfinispanCon
final ConfigurationBuilder actionTokenCacheConfigBuilder = getActionTokenCacheConfig(); final ConfigurationBuilder actionTokenCacheConfigBuilder = getActionTokenCacheConfig();
if (clustered) { if (clustered) {
actionTokenCacheConfigBuilder.simpleCache(false);
actionTokenCacheConfigBuilder.clustering().cacheMode(async ? CacheMode.REPL_ASYNC : CacheMode.REPL_SYNC); actionTokenCacheConfigBuilder.clustering().cacheMode(async ? CacheMode.REPL_ASYNC : CacheMode.REPL_SYNC);
} }
if (jdgEnabled) { if (jdgEnabled) {
@ -374,6 +377,7 @@ public class DefaultInfinispanConnectionProviderFactory implements InfinispanCon
private Configuration getRevisionCacheConfig(long maxEntries) { private Configuration getRevisionCacheConfig(long maxEntries) {
ConfigurationBuilder cb = createCacheConfigurationBuilder(); ConfigurationBuilder cb = createCacheConfigurationBuilder();
cb.simpleCache(false);
cb.invocationBatching().enable().transaction().transactionMode(TransactionMode.TRANSACTIONAL); cb.invocationBatching().enable().transaction().transactionMode(TransactionMode.TRANSACTIONAL);
// Use Embedded manager even in managed ( wildfly/eap ) environment. We don't want infinispan to participate in global transaction // Use Embedded manager even in managed ( wildfly/eap ) environment. We don't want infinispan to participate in global transaction

View file

@ -167,6 +167,9 @@ public class InfinispanUtil {
// need to force the encoding to application/x-java-object to avoid unnecessary conversion of keys/values. See WFLY-14356. // need to force the encoding to application/x-java-object to avoid unnecessary conversion of keys/values. See WFLY-14356.
builder.encoding().mediaType(MediaType.APPLICATION_OBJECT_TYPE); builder.encoding().mediaType(MediaType.APPLICATION_OBJECT_TYPE);
// needs to be disabled if transaction is enabled
builder.simpleCache(true);
return builder; return builder;
} }

View file

@ -23,14 +23,14 @@
<cache-container name="keycloak"> <cache-container name="keycloak">
<transport lock-timeout="60000"/> <transport lock-timeout="60000"/>
<local-cache name="realms"> <local-cache name="realms" simple-cache="true">
<encoding> <encoding>
<key media-type="application/x-java-object"/> <key media-type="application/x-java-object"/>
<value media-type="application/x-java-object"/> <value media-type="application/x-java-object"/>
</encoding> </encoding>
<memory max-count="10000"/> <memory max-count="10000"/>
</local-cache> </local-cache>
<local-cache name="users"> <local-cache name="users" simple-cache="true">
<encoding> <encoding>
<key media-type="application/x-java-object"/> <key media-type="application/x-java-object"/>
<value media-type="application/x-java-object"/> <value media-type="application/x-java-object"/>
@ -55,7 +55,7 @@
<distributed-cache name="loginFailures" owners="2"> <distributed-cache name="loginFailures" owners="2">
<expiration lifespan="-1"/> <expiration lifespan="-1"/>
</distributed-cache> </distributed-cache>
<local-cache name="authorization"> <local-cache name="authorization" simple-cache="true">
<encoding> <encoding>
<key media-type="application/x-java-object"/> <key media-type="application/x-java-object"/>
<value media-type="application/x-java-object"/> <value media-type="application/x-java-object"/>
@ -65,7 +65,7 @@
<replicated-cache name="work"> <replicated-cache name="work">
<expiration lifespan="-1"/> <expiration lifespan="-1"/>
</replicated-cache> </replicated-cache>
<local-cache name="keys"> <local-cache name="keys" simple-cache="true">
<encoding> <encoding>
<key media-type="application/x-java-object"/> <key media-type="application/x-java-object"/>
<value media-type="application/x-java-object"/> <value media-type="application/x-java-object"/>