Cache的疑惑??

由于想得脑袋都痛了,所以先放首页一回会儿,让大家一起讨论一下,还请dudu见谅
在设计Web应用程序的时候,性能可以说是最需要考虑的地方,使用cache是一个不错的选择,一直以来,我感觉Cache用来缓存小数量数据比较合适,但是今天在看Petshop的代码的时候 看到如下代码

ExpandedBlockStart.gif ContractedBlock.gif      if (Cache[categoryKey]  !=   null ) dot.gif {
InBlock.gif                
// If the data is already cached, then used the cached copy
InBlock.gif
                products.DataSource = (IList)Cache[categoryKey];
ExpandedBlockStart.gifContractedBlock.gif            }
else dot.gif {
InBlock.gif                
// If the data is not cached, then create a new products object and request the data
InBlock.gif
                Product product = new Product();
InBlock.gif                IList productsByCategory 
= product.GetProductsByCategory(categoryKey);
InBlock.gif                
// Store the results of the call in the Cache and set the time out to 12 hours
InBlock.gif
                Cache.Add(categoryKey, productsByCategory, null, DateTime.Now.AddHours(12), Cache.NoSlidingExpiration , CacheItemPriority.High, null);
InBlock.gif                products.DataSource 
= productsByCategory;
ExpandedBlockEnd.gif            }
代码不难理解。petshop是吧每一个分类的产品列表列据categorykey不同全部放在了缓存中,无疑,这样做访问时不用每次都访问数据库,在性能上有很大的提高,但是我在想,在petshop的演示数据库中 只有5个分类,而且第个分类也只有为数不多的产品,如果,分类,多达上百种,每个分类里面又有近千种的产品,用这种方式是否还合适,如果 不合适的话,为什么当初这个用演示,.Net的设计思想以及性能的程序 为什么采用了这种设计方法,难道只是用来表的小数据量为前题下的性能????
本来 我对Cache认识还是蛮清晰的,现在 被这段代码弄糊涂了,cache到底 缓存多少数据库量比较合适。
几十条。
几百条。
几千条。
上万条。
还是存个几百万条。
是不是我想太多了??
还请大家帮我解除这个疑惑,
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值