Remove Config Caching

This commit is contained in:
DerDavidBohl
2025-01-17 15:31:40 +01:00
parent c71800d7cb
commit 47b963cfa8
2 changed files with 1 additions and 42 deletions

View File

@@ -1,33 +0,0 @@
package org.davidbohl.dirigent.deployments.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
@Configuration
@EnableCaching
@EnableScheduling
public class CachingConfig {
private final Logger logger = LoggerFactory.getLogger(CachingConfig.class);
@Bean
public CacheManager cacheManager() {
return new ConcurrentMapCacheManager("deployments");
}
@CacheEvict(value = "deployments", allEntries = true)
@Scheduled(fixedRateString = "${dirigent.deployments.cache.evict.interval}")
public void emptyDeploymentsCache() {
logger.info("emptying deployments cache");
}
}

View File

@@ -5,8 +5,6 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import org.davidbohl.dirigent.deployments.service.GitService;
import org.davidbohl.dirigent.deployments.models.DeploynentConfiguration;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.cache.CacheManagerCustomizer;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
import org.springframework.stereotype.Service;
@@ -15,7 +13,7 @@ import java.io.IOException;
import java.util.List;
@Service
public class DeploymentsConfigurationProvider implements CacheManagerCustomizer<ConcurrentMapCacheManager> {
public class DeploymentsConfigurationProvider {
private final GitService gitService;
@@ -26,7 +24,6 @@ public class DeploymentsConfigurationProvider implements CacheManagerCustomizer<
this.gitService = gitService;
}
@Cacheable("deployments")
public DeploynentConfiguration getConfiguration() throws IOException, InterruptedException {
ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());
@@ -42,10 +39,5 @@ public class DeploymentsConfigurationProvider implements CacheManagerCustomizer<
throw e;
}
}
@Override
public void customize(ConcurrentMapCacheManager cacheManager) {
cacheManager.setCacheNames(List.of("deployments"));
}
}