spring缓存创建

    /**
     * 
     * <b>创建缓存</b>
     * <p>
     * 创建缓存,若已存在直接返回。
     * <p>
     * @param cacheName
     * @return Ehcache
     */
    public static Ehcache createCache(String cacheName)
    {
        Ehcache ehCache;
        CacheManager cacheManager = SpringContextHolder.getBean(CacheManager.class);
        if (cacheManager.cacheExists(cacheName)) {
            if (logger.isDebugEnabled()) {
                logger.debug("Using existing EHCache cache region '" + cacheName + "'");
            }
            ehCache = cacheManager.getEhcache(cacheName);
        }
        else {
            if (logger.isDebugEnabled()) {
                logger.debug("Creating new EHCache cache region '" + cacheName + "'");
            }
            ehCache = createDefaultCache(cacheName);
            cacheManager.addCache(ehCache);
        }
        return ehCache;
    }

 

上一篇:LiveLink™ for MATLAB:COMSOL与MATLAB交互


下一篇:机器学习PAL基本概念