Created
June 16, 2023 17:21
-
-
Save Szer/7ced38e3194a842c8223a5abbe7bdcc6 to your computer and use it in GitHub Desktop.
Keycloak patch for KC storages
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
/* | |
* Copyright 2016 Red Hat, Inc. and/or its affiliates | |
* and other contributors as indicated by the @author tags. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and | |
* limitations under the License. | |
*/ | |
package org.keycloak.models.sessions.infinispan; | |
import org.infinispan.AdvancedCache; | |
import org.infinispan.Cache; | |
import org.infinispan.context.Flag; | |
/** | |
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a> | |
*/ | |
public class CacheDecorators { | |
// Patch:Begin | |
private static final boolean IGNORE_SKIP_CACHE_STORE = Boolean.getBoolean("keycloak.infinispan.ignoreSkipCacheStore"); | |
// Patch:End | |
/** | |
* Adds {@link Flag#CACHE_MODE_LOCAL} flag to the cache. | |
* @param cache | |
* @return Cache with the flag applied. | |
*/ | |
public static <K, V> AdvancedCache<K, V> localCache(Cache<K, V> cache) { | |
return cache.getAdvancedCache().withFlags(Flag.CACHE_MODE_LOCAL); | |
} | |
/** | |
* Adds {@link Flag#SKIP_CACHE_LOAD} and {@link Flag#SKIP_CACHE_STORE} flags to the cache. | |
* @param cache | |
* @return Cache with the flags applied. | |
*/ | |
public static <K, V> AdvancedCache<K, V> skipCacheLoaders(Cache<K, V> cache) { | |
return cache.getAdvancedCache().withFlags(Flag.SKIP_CACHE_LOAD, Flag.SKIP_CACHE_STORE); | |
} | |
/** | |
* Adds {@link Flag#SKIP_CACHE_STORE} flag to the cache. | |
* @param cache | |
* @return Cache with the flags applied. | |
*/ | |
public static <K, V> AdvancedCache<K, V> skipCacheStore(Cache<K, V> cache) { | |
// Patch:Begin | |
if (IGNORE_SKIP_CACHE_STORE) { | |
return cache.getAdvancedCache(); | |
} | |
// Patch:End | |
return cache.getAdvancedCache().withFlags(Flag.SKIP_CACHE_STORE); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment