From fd1f3c52d39537da6091bf8200db37d487ea613e Mon Sep 17 00:00:00 2001 From: Alexander Schwartz Date: Fri, 27 Sep 2024 18:05:01 +0200 Subject: [PATCH] Further optimizations Closes #33353 Signed-off-by: Alexander Schwartz --- .../organization/InfinispanOrganizationProvider.java | 2 +- .../cache/infinispan/organization/OrganizationAdapter.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/organization/InfinispanOrganizationProvider.java b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/organization/InfinispanOrganizationProvider.java index 2ab2cc48e0..de76a5cf33 100644 --- a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/organization/InfinispanOrganizationProvider.java +++ b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/organization/InfinispanOrganizationProvider.java @@ -245,7 +245,7 @@ public class InfinispanOrganizationProvider implements OrganizationProvider { String cacheKey = cacheKeyMembership(getRealm(), organization, member); CachedMembership cached = realmCache.getCache().get(cacheKey, CachedMembership.class); - if (cached == null) { + if (cached == null && !isInvalid(cacheKey)) { return getDelegate().isManagedMember(organization, user); } diff --git a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/organization/OrganizationAdapter.java b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/organization/OrganizationAdapter.java index 22b602c8aa..aee743f0c8 100644 --- a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/organization/OrganizationAdapter.java +++ b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/organization/OrganizationAdapter.java @@ -153,12 +153,14 @@ public class OrganizationAdapter implements OrganizationModel { @Override public boolean isManaged(UserModel user) { - return delegate.get().isManagedMember(this, user); + if (isUpdated()) delegate.get().isManagedMember(this, user); + return organizationCache.isManagedMember(this, user); } @Override public boolean isMember(UserModel user) { - return delegate.get().isMember(this, user); + if (isUpdated()) delegate.get().isMember(this, user); + return organizationCache.isMember(this, user); } @Override