OFBiz的Cache研究

任何一个cache对象的配置属性都可以在cache.properties设置。

{cache-name}.maxSize (内存大小)
{cache-name}.expireTime (失效时间)
{cache-name}.useSoftReference (true 或者 false).
该useSoftReference属性用于指定是否用于缓存条目。可以帮助保持大缓存,同时需要更多的内存垃圾回收器来清除这些项目占用过多内存。


例如
//    # 60 min
// product.ecconfig.expireTime=3600000
// product.ecconfig.useSoftReference=true
public static UtilCache productCache = UtilCache.createUtilCache("product.ecconfig", true);


使用
if(UtilValidate.isNotEmpty(productCache.get(condition))){
long count =(Long) productCache.get(condition);
if(count>0){result="Y";}
else{result="N";}
return result;
}

try {
long count = delegator.findCountByCondition("EcShopProduct", condition, null, null);
productCache.put(condition, count);
Debug.log(" productCategoryId="+productCategoryId+" productFeatureList="+productFeatureList+" count="+count, module);
if(count>0){result="Y";}
} catch (GenericEntityException e) {
Debug.logError(e.getMessage(), module);
return result;
}



缓存工具
缓存管理
浏览缓存大小和命中/错失统计
清除全部缓存、单独的缓存甚至单独的缓存行
清除全部过期的缓存记录
管理缓存参数如大小限止、过期时间、软参考等
浏览每个缓存中的单独的元素

附cache的通用使用方法
http://www.amicontech.com/blog/caching-in-opentaps-ofbiz/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值