package com.newvideo.service.imp; import javax.annotation.Resource; import org.springframework.cache.ehcache.EhCacheCacheManager; import org.springframework.stereotype.Service; import com.newvideo.log.LogHelper; import net.sf.ehcache.Cache; @Service public class CacheService { @Resource private EhCacheCacheManager cacheManager; public void printMsg() { String[] sts = cacheManager.getCacheManager().getCacheNames(); for (String st : sts) { Cache cache = cacheManager.getCacheManager().getCache(st); LogHelper.ehcacheInfo(cache.getStatistics().toString()); } } public void clearCacheKey(String cacheName, String key) { Cache cache = cacheManager.getCacheManager().getCache(cacheName); if (cache != null) cache.remove(key); } }