package net.vtstar.zhongtong.avi.global.config;

import org.springframework.cache.Cache;
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.context.annotation.Primary;

@Configuration
@EnableCaching
public class CacheConfig {

    @Bean
    @Primary
    ConcurrentMapCacheManager cacheManager() {
        ConcurrentMapCacheManager cacheManager = new ConcurrentMapCacheManager();
        return cacheManager;
    }

    @Bean
    Cache showFieldCache(ConcurrentMapCacheManager cacheManager) {
        return cacheManager.getCache("showFieldCache");
    }

    @Bean
    Cache classNameCache(ConcurrentMapCacheManager cacheManager) {
        return cacheManager.getCache("classNameCache");
    }

    @Bean
    Cache stationCache(ConcurrentMapCacheManager cacheManager) {
        return cacheManager.getCache("stationCache");
    }

    @Bean
    Cache laneStationCache(ConcurrentMapCacheManager cacheManager) {
        return cacheManager.getCache("laneStationCache");
    }

    @Bean
    Cache vehicleCache(ConcurrentMapCacheManager cacheManager) {
        return cacheManager.getCache("vehicleCache");
    }

    @Bean
    Cache skidCache(ConcurrentMapCacheManager cacheManager) {
        return cacheManager.getCache("skidCache");
    }

    @Bean
    Cache webStationCache(ConcurrentMapCacheManager cacheManager) {
        return cacheManager.getCache("webStationCache");
    }

    @Bean
    Cache warningCache(ConcurrentMapCacheManager cacheManager) {
        return cacheManager.getCache("warningCache");
    }

    @Bean
    Cache roomCache(ConcurrentMapCacheManager cacheManager) {
        return cacheManager.getCache("roomCache");
    }
}
