mirror of
https://github.com/DerDavidBohl/dirigent-spring.git
synced 2026-01-04 01:19:33 -06:00
Remove Config Caching
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user