Example usage for org.springframework.cache CacheManager getCacheNames

List of usage examples for org.springframework.cache CacheManager getCacheNames

Introduction

In this page you can find the example usage for org.springframework.cache CacheManager getCacheNames.

Prototype

Collection<String> getCacheNames();

Source Link

Document

Get a collection of the cache names known by this manager.

Usage

From source file:org.hsweb.web.controller.monitor.CacheMonitorController.java

protected long getTimes(CacheManager cacheManager, TimesGetter getter) {
    long times = cacheManager.getCacheNames().parallelStream().map(name -> cacheManager.getCache(name))
            .filter(cache -> cache instanceof MonitorCache).map(cache -> (MonitorCache) cache)
            .mapToLong(getter::get).reduce((i1, i2) -> i1 + i2).orElseGet(() -> 0);
    return times;
}

From source file:org.obiba.mica.config.CacheConfiguration.java

@Bean
public CacheManager springCacheManager() {
    log.debug("Starting Spring Cache");
    net.sf.ehcache.CacheManager cacheManager = cacheManagerFactory().getObject();
    EhCacheCacheManager ehCacheManager = new EhCacheCacheManager();
    ehCacheManager.setCacheManager(cacheManager);
    String[] cacheNames = cacheManager.getCacheNames();
    for (String cacheName : cacheNames) {
        Cache cache = cacheManager.getCache(cacheName);
        cacheManager.replaceCacheWithDecoratedCache(cache,
                InstrumentedEhcache.instrument(metricRegistry, cache));
    }/*from   w w w  .j ava2s .c  om*/
    return ehCacheManager;
}

From source file:org.hsweb.web.controller.monitor.CacheMonitorController.java

@RequestMapping(value = "/cache/{name:.+}", method = RequestMethod.GET)
@AccessLogger("???")
public ResponseMessage getNameList(@PathVariable("name") String name) {
    CacheManager cacheManager = cacheManagerMap.get(name);
    if (cacheManager != null) {
        return ResponseMessage.ok(cacheManager.getCacheNames());
    }/*w w w .  j a va  2  s.  c  om*/
    throw new NotFoundException("?");
}

From source file:org.ngrinder.infra.config.Config.java

private void updateCacheStatisticsSupports() {
    CacheManager cacheManager = appContext.getBean("cacheManager", CacheManager.class);
    boolean enableStatistics = isEnableStatistics();
    for (String cacheName : cacheManager.getCacheNames()) {
        Cache cache = cacheManager.getCache(cacheName);
        ((net.sf.ehcache.Cache) cache.getNativeCache()).setStatisticsEnabled(enableStatistics);
    }//from   www .j  a  va 2s.co m
}