6 changed files with 82 additions and 42 deletions
@ -0,0 +1,45 @@ |
|||
package app.configurations; |
|||
|
|||
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.Scheduled; |
|||
|
|||
import java.util.concurrent.TimeUnit; |
|||
|
|||
@Configuration |
|||
@EnableCaching |
|||
public class AppCacheConfig { |
|||
private static final Logger logger = LoggerFactory.getLogger(AppCacheConfig.class); |
|||
|
|||
public static final String g_usertime = "graphs.usertime"; |
|||
public static final String g_vip = "graphs.vip"; |
|||
public static final String g_online = "graphs.online"; |
|||
public static final String g_usertime_connections = "graphs.usertime.connections"; |
|||
|
|||
@Bean |
|||
public CacheManager cacheManager() { |
|||
return new ConcurrentMapCacheManager( |
|||
"steam_data", |
|||
"steam_search_data", |
|||
g_usertime, |
|||
g_vip, |
|||
g_online, |
|||
g_usertime_connections); |
|||
} |
|||
|
|||
@Scheduled(fixedRate = 1, timeUnit = TimeUnit.HOURS) |
|||
public void purgeCacheSched() { |
|||
purgeGraphCache(); |
|||
} |
|||
|
|||
@CacheEvict(value = {g_usertime, g_vip, g_online, g_usertime_connections}, allEntries = true) |
|||
public void purgeGraphCache() { |
|||
logger.info("Cache clean of graphs"); |
|||
} |
|||
} |
|||
@ -1,22 +0,0 @@ |
|||
package app.configurations; |
|||
|
|||
import org.springframework.cache.CacheManager; |
|||
import org.springframework.cache.annotation.EnableCaching; |
|||
import org.springframework.cache.concurrent.ConcurrentMapCacheManager; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
|
|||
@Configuration |
|||
@EnableCaching |
|||
public class CacheConfig { |
|||
@Bean |
|||
public CacheManager cacheManager() { |
|||
return new ConcurrentMapCacheManager( |
|||
"steam_data", |
|||
"steam_search_data", |
|||
"graphs.usertime", |
|||
"graphs.vip", |
|||
"graphs.online", |
|||
"graphs.usertime.connections"); |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
package app.configurations; |
|||
|
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.scheduling.annotation.EnableScheduling; |
|||
|
|||
import java.util.concurrent.TimeUnit; |
|||
|
|||
@Configuration |
|||
@EnableScheduling |
|||
public class ScheduledConfig { |
|||
private static final TimeUnit defaultUnit = TimeUnit.HOURS; |
|||
private static final int defaultDuration = 1; |
|||
private static final Logger logger = LoggerFactory.getLogger(ScheduledConfig.class); |
|||
|
|||
public ScheduledConfig() { |
|||
logger.info("Enabled scheduling"); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue