use of net.sf.ehcache.Cache in project hibernate-orm by hibernate.
the class EhcacheStatsImpl method getRegionCacheSamples.
@Override
public Map<String, int[]> getRegionCacheSamples() {
final Map<String, int[]> rv = new HashMap<String, int[]>();
for (String name : cacheManager.getCacheNames()) {
final Cache cache = cacheManager.getCache(name);
if (cache != null) {
final Double hits = cache.getStatistics().cacheHitOperation().rate().value();
final Double misses = cache.getStatistics().cacheMissNotFoundOperation().rate().value();
final Double expired = cache.getStatistics().cacheMissExpiredOperation().rate().value();
final Double puts = cache.getStatistics().cachePutOperation().rate().value();
rv.put(name, new int[] { hits.intValue(), misses.intValue(), expired.intValue(), puts.intValue() });
}
}
return rv;
}
use of net.sf.ehcache.Cache in project hibernate-orm by hibernate.
the class EhcacheStatsImpl method setRegionCacheTargetMaxInMemoryCount.
@Override
public void setRegionCacheTargetMaxInMemoryCount(String region, int targetMaxInMemoryCount) {
final Cache cache = this.cacheManager.getCache(region);
if (cache != null) {
cache.getCacheConfiguration().setMaxElementsInMemory(targetMaxInMemoryCount);
sendNotification(CACHE_REGION_CHANGED, getRegionCacheAttributes(region), region);
}
}
use of net.sf.ehcache.Cache in project hibernate-orm by hibernate.
the class EhcacheStatsImpl method setRegionCacheTargetMaxTotalCount.
@Override
public void setRegionCacheTargetMaxTotalCount(String region, int targetMaxTotalCount) {
final Cache cache = this.cacheManager.getCache(region);
if (cache != null) {
cache.getCacheConfiguration().setMaxElementsOnDisk(targetMaxTotalCount);
sendNotification(CACHE_REGION_CHANGED, getRegionCacheAttributes(region), region);
}
}
use of net.sf.ehcache.Cache in project CloudStack-archive by CloudStack-extras.
the class GenericDaoBase method createCache.
@DB(txn = false)
protected void createCache(final Map<String, ? extends Object> params) {
final String value = (String) params.get("cache.size");
if (value != null) {
final CacheManager cm = CacheManager.create();
final int maxElements = NumbersUtil.parseInt(value, 0);
final int live = NumbersUtil.parseInt((String) params.get("cache.time.to.live"), 300);
final int idle = NumbersUtil.parseInt((String) params.get("cache.time.to.idle"), 300);
_cache = new Cache(getName(), maxElements, false, live == -1, live == -1 ? Integer.MAX_VALUE : live, idle);
cm.addCache(_cache);
s_logger.info("Cache created: " + _cache.toString());
} else {
_cache = null;
}
}
use of net.sf.ehcache.Cache in project ORCID-Source by ORCID.
the class OrcidEhCacheFactoryBean method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
Ehcache existingCache = cacheManager.getEhcache(cacheName);
String diskStorePath = cacheManager.getConfiguration().getDiskStoreConfiguration().getPath();
LOGGER.debug("Cache manager disk store path = " + diskStorePath);
if (existingCache == null) {
CacheConfiguration config = createConfig();
if (cacheEntryFactory != null) {
this.cache = new SelfPopulatingCache(new Cache(config), cacheEntryFactory);
} else {
this.cache = new Cache(config);
}
cacheManager.addCache(this.cache);
} else {
this.cache = existingCache;
}
}
Aggregations