admin
2021-04-12 5129d2c63fbef70c6ee45ba5ec12654937e05231
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.yeshi.buwan.service.imp;
 
import javax.annotation.Resource;
 
import org.springframework.cache.ehcache.EhCacheCacheManager;
import org.springframework.stereotype.Service;
 
import com.yeshi.buwan.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);
    }
 
}