RED-6224: Fixed non working redis config for user cache
This commit is contained in:
parent
a8c0ad42d1
commit
904de033a0
@ -1,5 +1,7 @@
|
||||
package com.iqser.red.persistence.service.v1.external.api.impl.service;
|
||||
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.cache.PersistenceServiceExternalApiCacheConfiguration.OTT_CACHE;
|
||||
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -9,8 +11,6 @@ import com.iqser.red.persistence.service.v1.external.api.impl.model.OneTimeToken
|
||||
@Service
|
||||
public class OneTimeTokenCacheService {
|
||||
|
||||
public static final String OTT_CACHE = "ott";
|
||||
|
||||
|
||||
@Cacheable(value = OTT_CACHE, key = "#tokenId")
|
||||
public OneTimeToken cacheOTT(String tokenId, OneTimeToken token) {
|
||||
|
||||
@ -1,22 +1,34 @@
|
||||
package com.iqser.red.persistence.service.v1.external.api.impl.cache;
|
||||
|
||||
import static com.iqser.red.persistence.service.v1.external.api.impl.service.OneTimeTokenCacheService.OTT_CACHE;
|
||||
package com.iqser.red.service.persistence.management.v1.processor.cache;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import org.springframework.boot.autoconfigure.cache.RedisCacheManagerBuilderCustomizer;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
||||
|
||||
@EnableCaching
|
||||
@Configuration
|
||||
public class PersistenceServiceExternalApiCacheConfiguration {
|
||||
|
||||
public static final String RATE_LIMITER_CACHE = "buckets";
|
||||
public static final String ACL_CACHE = "acl";
|
||||
public static final String OTT_CACHE = "ott";
|
||||
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public RedisCacheManager redisCacheManager(RedisConnectionFactory connectionFactory) {
|
||||
|
||||
return RedisCacheManager.create(connectionFactory);
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
@ -33,9 +45,10 @@ public class PersistenceServiceExternalApiCacheConfiguration {
|
||||
public RedisCacheManagerBuilderCustomizer redisCacheManagerBuilderCustomizer() {
|
||||
|
||||
return (builder) -> builder.withCacheConfiguration(RATE_LIMITER_CACHE, RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofMinutes(60)))
|
||||
.withCacheConfiguration(ACL_CACHE, RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofMinutes(1)).serializeValuesWith(
|
||||
RedisSerializationContext.SerializationPair.fromSerializer(new JdkSerializationRedisSerializer()))
|
||||
)
|
||||
.withCacheConfiguration(ACL_CACHE,
|
||||
RedisCacheConfiguration.defaultCacheConfig()
|
||||
.entryTtl(Duration.ofMinutes(1))
|
||||
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(new JdkSerializationRedisSerializer())))
|
||||
.withCacheConfiguration(OTT_CACHE, RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofSeconds(10)));
|
||||
}
|
||||
|
||||
@ -32,12 +32,12 @@ public class KeyCloakUserSyncService {
|
||||
|
||||
tenantManagementService.getTenants().forEach(tenant -> {
|
||||
|
||||
TenantContext.setTenantId(tenant.getTenantId());
|
||||
|
||||
var allUsers = userListingService.getAllUsers(tenant.getTenantId());
|
||||
// all userIds from KC
|
||||
var allUserIds = allUsers.stream().map(User::getUserId).collect(Collectors.toSet());
|
||||
|
||||
TenantContext.setTenantId(tenant.getTenantId());
|
||||
|
||||
var redactionObjectsUserIds = new HashSet<String>();
|
||||
|
||||
var alLDossiers = dossierManagementService.getAllDossiers(true, true);
|
||||
@ -55,6 +55,8 @@ public class KeyCloakUserSyncService {
|
||||
redactionObjectsUserIds.forEach(removedUser -> alLDossiers.forEach(dossier -> this.userService.updateDossierUsers(removedUser,
|
||||
UserService.UserRemovalModel.PERMANENT,
|
||||
dossier)));
|
||||
|
||||
TenantContext.clear();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@ -24,9 +24,9 @@ import com.giffing.bucket4j.spring.boot.starter.config.webflux.Bucket4JAutoConfi
|
||||
import com.iqser.red.keycloak.commons.DefaultKeyCloakCommonsConfiguration;
|
||||
import com.iqser.red.keycloak.commons.KeyCloakSettings;
|
||||
import com.iqser.red.persistence.service.v1.external.api.impl.PersistenceServiceExternalApiConfiguration;
|
||||
import com.iqser.red.persistence.service.v1.external.api.impl.cache.PersistenceServiceExternalApiCacheConfiguration;
|
||||
import com.iqser.red.persistence.service.v1.external.api.impl.swagger.SwaggerAutoConfiguration;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.PersistenceServiceProcessorConfiguration;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.cache.PersistenceServiceExternalApiCacheConfiguration;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.configuration.CleanupDownloadSchedulerConfiguration;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.configuration.MessagingConfiguration;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.multitenancy.AsyncConfig;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user