Repository navigation
Replies: 3 comments 9 replies
|
Hi @dteleguin, this sounds really nice! My (personal) main focus would be the embedded use cases and perhaps it's worth to focus on that in first sight!? I've a few questions/ideas: From your And also in best case, In If I'm wrong or if I misunderstand something, please give me a little more insight to your thoughts/ideas. |
|
@dteleguin, my 2 cents, way too complex. A single method should be fine: // returns the caches to configure
Stream<CacheDefinition> getCaches(DeploymentMode mode);
record CacheDefinition(
String name, //name
Configuration configuration, // configuration to use
List<String>indexedEntities) // indexed entity for remote
enum DeploymentMode {
LOCAL, // local mode only means no JGroups or cluster is available. must use local caches only
CLUSTERED, // embedded cache with clustering available
EXTERNAL // external cache
}No mention of schemas since they are loaded at build time here and automatically registered in the embedded caches. We just need to register them in the external caches. ps. I'm shit with names, feel free to come up with a better name. Let me know what you think. |
|
I am a bit worried as this is jumping from "I want to use caching for Authenticators" to "and this is how I want to do it with Infinispan/Caching". To me. this is all about discussing the how, but now the why and the requirements. Without knowing those requirements everyone has probably something else in mind. Once we have the SPI, it would be hard to explain what it should be used for, and what not. Do you want to store state or actually cache information that is stored somewhere else? What is the cost of losing the data that is stored in memory? How many entries do you want to store and for how long? How large is each entry? How many read and write operations do you want to perform per second? How is the number determined, for example does it need to scale with the number of interactive logins? Why are you looking for a distributed store and not a local one? Did you consider putting the information into the database? What other existing options did you consider? What is your cache hit ratio? What is the cost of stale data? What operations do you want to execute on those caches - the abstraction shown above leaks a lot of Infinispan internals, and therefore Infinispan might be the only implemention to satisfy it. This is a pattern we usually want to avoid. |
Uh oh!
There was an error while loading. Please reload this page.
Cache SPI
Motivation
For the Keycloak custom components like Authenticators, it is a valid requirement to have a distributed data layer. It is totally possible to create custom Infinispan caches in Keycloak; however, the process is not straightforward. The code that Keycloak uses to implement its internal caches is not easily reusable because of specific class/interface hierarchy, private fields/methods etc. Therefore, supporting a custom cache currently requires a lot of copy-pasted code, which results in poor maintainability.
This becomes even more complicated with remote Infinispan (aka multi-site / clusterless mode).
Currently, a power user wanting to implement a custom cache needs to cover the following aspects:
¹ <26.2, see #34971
² <26.3, not implemented in recent Keycloak versions
The proposed Cache SPI should allow power users to declare/describe their caches, and let Keycloak do the heavy lifting, thus encouraging code reuse and resulting in better code quality.
Design
org.keycloak.spi.infinispanorg.keycloak.spi.infinispan.CacheSpiorg.keycloak.spi.infinispan.CacheProviderFactoryorg.keycloak.spi.infinispan.CacheProviderAll reactions