本文整理汇总了Java中net.sf.ehcache.Ehcache.getKeys方法的典型用法代码示例。如果您正苦于以下问题:Java Ehcache.getKeys方法的具体用法?Java Ehcache.getKeys怎么用?Java Ehcache.getKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.ehcache.Ehcache
的用法示例。
在下文中一共展示了Ehcache.getKeys方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: keys
import net.sf.ehcache.Ehcache; //导入方法依赖的package包/类
@Override
public Set keys() {
if(springCache.getNativeCache() instanceof Ehcache) {
Ehcache ehcache = (Ehcache) springCache.getNativeCache();
return new HashSet(ehcache.getKeys());
}
throw new UnsupportedOperationException("invoke spring cache abstract keys method not supported");
}
示例2: keys
import net.sf.ehcache.Ehcache; //导入方法依赖的package包/类
@Override
public Set keys() {
if (springCache.getNativeCache() instanceof Ehcache) {
Ehcache ehcache = (Ehcache) springCache.getNativeCache();
return new HashSet(ehcache.getKeys());
}
throw new UnsupportedOperationException(
"invoke spring cache abstract keys method not supported");
}
示例3: keys
import net.sf.ehcache.Ehcache; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public Set<K> keys() {
if(cache.getNativeCache() instanceof Ehcache) {
Ehcache ehcache = (Ehcache) cache.getNativeCache();
return new HashSet<K>(ehcache.getKeys());
}
throw new UnsupportedOperationException("invoke spring cache abstract keys method not supported");
}
示例4: keys
import net.sf.ehcache.Ehcache; //导入方法依赖的package包/类
@Override
public Set keys() {
if (springCache.getNativeCache() instanceof Ehcache) {
Ehcache ehcache = (Ehcache) springCache.getNativeCache();
return new HashSet(ehcache.getKeys());
}
throw new UnsupportedOperationException("invoke spring cache abstract keys method not supported");
}
示例5: updateHits
import net.sf.ehcache.Ehcache; //导入方法依赖的package包/类
/**
* 更新点击数
*/
@SuppressWarnings("unchecked")
private void updateHits() {
Ehcache cache = cacheManager.getEhcache(Article.HITS_CACHE_NAME);
List<Long> ids = cache.getKeys();
for (Long id : ids) {
Article article = articleDao.find(id);
if (article != null) {
Element element = cache.get(id);
long hits = (Long) element.getObjectValue();
article.setHits(hits);
articleDao.merge(article);
}
}
}
示例6: updateHits
import net.sf.ehcache.Ehcache; //导入方法依赖的package包/类
/**
* 更新点击数
*/
@SuppressWarnings("unchecked")
private void updateHits() {
Ehcache cache = cacheManager.getEhcache(Product.HITS_CACHE_NAME);
List<Long> ids = cache.getKeys();
for (Long id : ids) {
Product product = productDao.find(id);
if (product != null) {
productDao.lock(product, LockModeType.PESSIMISTIC_WRITE);
Element element = cache.get(id);
long hits = (Long) element.getObjectValue();
long increment = hits - product.getHits();
Calendar nowCalendar = Calendar.getInstance();
Calendar weekHitsCalendar = DateUtils.toCalendar(product.getWeekHitsDate());
Calendar monthHitsCalendar = DateUtils.toCalendar(product.getMonthHitsDate());
if (nowCalendar.get(Calendar.YEAR) != weekHitsCalendar.get(Calendar.YEAR) || nowCalendar.get(Calendar.WEEK_OF_YEAR) > weekHitsCalendar.get(Calendar.WEEK_OF_YEAR)) {
product.setWeekHits(increment);
} else {
product.setWeekHits(product.getWeekHits() + increment);
}
if (nowCalendar.get(Calendar.YEAR) != monthHitsCalendar.get(Calendar.YEAR) || nowCalendar.get(Calendar.MONTH) > monthHitsCalendar.get(Calendar.MONTH)) {
product.setMonthHits(increment);
} else {
product.setMonthHits(product.getMonthHits() + increment);
}
product.setHits(hits);
product.setWeekHitsDate(new Date());
product.setMonthHitsDate(new Date());
productDao.merge(product);
}
}
}
示例7: keys
import net.sf.ehcache.Ehcache; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public Set keys() {
if(springCache.getNativeCache() instanceof Ehcache) {
Ehcache ehcache = (Ehcache) springCache.getNativeCache();
return new HashSet(ehcache.getKeys());
}
throw new UnsupportedOperationException("invoke spring cache abstract keys method not supported");
}