请问,我这样做是不是很浪费资源啊???
请问,我得担心有必要吗?真的如我所料很浪费吗?如果有必要,我该怎么做来改变这种情况??????请回答,谢谢
你的用户数据是在数据库中吗?
请问是什么意思啊?????
hxz
我的数据是放在数据库里.
BANG
你的意思是第一次初始化后将他放在SESSION或CASH里面,以后再用同样的USER时,就从SESSION或CASH里面取????
谢谢你们的指点!!
它可以解决你的问题。当你只需要访问用户名字时,你可以只实例化Key,节约资源,如果想要访问用户的别的属性,无缝的用getUserByKey取得。
In general, you need a mechanism that can selective cache any table( cache from Expresso is a good ref), with basic control ( LRU or usage count), at least use a weak referenced hashmap to avoid overload. If the cached info is not read only, you'd better make it a class, it's smart enough to sync itself with DB and cache when change happens.