admin
2021-01-04 aa6ef62aef83e277d4171df1d9f0803f91738216
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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);
    }
 
}