PolicyEvaluationCacheConfig { @Bean public PolicyEvaluationCache cache(@Value("${ENABLE_DECISION_CACHING:true}") final boolean cachingEnabled) { if (!cachingEnabled) { LOGGER.info("Caching disabled for policy evaluation"); return new NonCachingPolicyEvaluationCache(); } List<String> activeProfiles = Arrays.asList(this.environment.getActiveProfiles()); if (activeProfiles.contains("redis") || activeProfiles.contains("cloud-redis")) { LOGGER.info("Redis caching enabled for policy evaluation."); return new RedisPolicyEvaluationCache(); } LOGGER.info("In-memory caching enabled for policy evaluation."); return new InMemoryPolicyEvaluationCache(); }  @Bean PolicyEvaluationCache cache(@Value("${ENABLE_DECISION_CACHING:true}") final boolean cachingEnabled);  }
@Test public void testPolicyEvaluationCacheConfigDisabled() { setupEnvironment(null); assertThat(policyEvaluationCacheConfig.cache(false), instanceOf(NonCachingPolicyEvaluationCache.class)); }
@Test public void testPolicyEvaluationCacheConfigRedis() { setupEnvironment("redis"); assertThat(policyEvaluationCacheConfig.cache(true), instanceOf(RedisPolicyEvaluationCache.class)); }
@Test public void testPolicyEvaluationCacheConfigCloudRedis() { setupEnvironment("cloud-redis"); assertThat(policyEvaluationCacheConfig.cache(true), instanceOf(RedisPolicyEvaluationCache.class)); }