@Override public UserConsentModel getConsentByClient(RealmModel realm, String userId, String clientId) { logger.tracev("getConsentByClient: {0}", userId); String cacheKey = getConsentCacheKey(userId); if (realmInvalidations.contains(realm.getId()) || invalidations.contains(userId) || invalidations.contains(cacheKey)) { return getDelegate().getConsentByClient(realm, userId, clientId); } CachedUserConsents cached = cache.get(cacheKey, CachedUserConsents.class); if (cached == null) { Long loaded = cache.getCurrentRevision(cacheKey); List<UserConsentModel> consents = getDelegate().getConsents(realm, userId); cached = new CachedUserConsents(loaded, cacheKey, realm, consents); cache.addRevisioned(cached, startupRevision); } CachedUserConsent cachedConsent = cached.getConsents().get(clientId); if (cachedConsent == null) return null; return toConsentModel(realm, cachedConsent); }
@Override public List<UserConsentModel> getConsents(RealmModel realm, String userId) { logger.tracev("getConsents: {0}", userId); String cacheKey = getConsentCacheKey(userId); if (realmInvalidations.contains(realm.getId()) || invalidations.contains(userId) || invalidations.contains(cacheKey)) { return getDelegate().getConsents(realm, userId); } CachedUserConsents cached = cache.get(cacheKey, CachedUserConsents.class); if (cached == null) { Long loaded = cache.getCurrentRevision(cacheKey); List<UserConsentModel> consents = getDelegate().getConsents(realm, userId); cached = new CachedUserConsents(loaded, cacheKey, realm, consents); cache.addRevisioned(cached, startupRevision); return consents; } else { List<UserConsentModel> result = new LinkedList<>(); for (CachedUserConsent cachedConsent : cached.getConsents().values()) { UserConsentModel consent = toConsentModel(realm, cachedConsent); if (consent != null) { result.add(consent); } } return result; } }
@Override public Set<FederatedIdentityModel> getFederatedIdentities(UserModel user, RealmModel realm) { logger.tracev("getFederatedIdentities: {0}", user.getUsername()); String cacheKey = getFederatedIdentityLinksCacheKey(user.getId()); if (realmInvalidations.contains(realm.getId()) || invalidations.contains(user.getId()) || invalidations.contains(cacheKey)) { return getDelegate().getFederatedIdentities(user, realm); } CachedFederatedIdentityLinks cachedLinks = cache.get(cacheKey, CachedFederatedIdentityLinks.class); if (cachedLinks == null) { Long loaded = cache.getCurrentRevision(cacheKey); Set<FederatedIdentityModel> federatedIdentities = getDelegate().getFederatedIdentities(user, realm); cachedLinks = new CachedFederatedIdentityLinks(loaded, cacheKey, realm, federatedIdentities); cache.addRevisioned(cachedLinks, startupRevision); return federatedIdentities; } else { return new HashSet<>(cachedLinks.getFederatedIdentities()); } }
if (adapter instanceof UserAdapter) { query = new UserListQuery(loaded, cacheKey, realm, model.getId()); cache.addRevisioned(query, startupRevision);
if (adapter instanceof UserAdapter) { query = new UserListQuery(loaded, cacheKey, realm, model.getId()); cache.addRevisioned(query, startupRevision);
if (adapter instanceof UserAdapter) { // this was cached, so we can cache query too query = new UserListQuery(loaded, cacheKey, realm, model.getId()); cache.addRevisioned(query, startupRevision);
if (adapter instanceof UserAdapter) { // this was cached, so we can cache query too query = new UserListQuery(loaded, cacheKey, realm, model.getId()); cache.addRevisioned(query, startupRevision);
cache.addRevisioned(cached, startupRevision, lifespan); } else { cache.addRevisioned(cached, startupRevision); adapter = new UserAdapter(cached, this, session, realm); onCache(realm, adapter, delegate); cache.addRevisioned(cached, startupRevision);