How to use @Cacheable control by parameter ?

37 views
Skip to first unread message

Minsoo,song

unread,
Nov 2, 2012, 2:40:04 AM11/2/12
to ehcache-sprin...@googlegroups.com
hi.
 
I use mysql master/slave replications.
 
master db query is not cache but slave query cached.
 
if cmd.isUseCache()==true , use cache
else not use cache
 
how to it?
 
===================================================
 
 @Cacheable(cacheName="GoodsManagerCache")
public List<Goods> findGoods(GoodsSearchCommand cmd) {
  if(cmd.isUseCache()==true)
       list=this.goodsSlaveDao.selectGoods(cmd);
  else
       list=this.goodsMasterDao.selectGoods(cmd);
}
 

Udo Kuehne

unread,
Nov 2, 2012, 4:21:59 AM11/2/12
to ehcache-sprin...@googlegroups.com
Moin,

your code snippet is not enough. Which framework or strategy do use?
E. g., Standard-JEE (javax.persistence), Spring 3.1.3,  JPA2.0, ...

You should read usefully information about Second Level Caching :
http://blog.newsplore.com/2009/05/28/a-call-to-standardize-level-2-cache-configuration-in-jpa-20

--
bye Udoline


2012/11/2 Minsoo,song <song...@gmail.com>
Reply all
Reply to author
Forward
0 new messages