简体   繁体   English

ASP.NET缓存层与业务逻辑层

[英]ASP.NET Caching Layer Vs Business Logic Layer

I'm looking for some helpful advice on how the caching layer in an ASP.NET project should work with the business logic layer. 我正在寻找有关ASP.NET项目中的缓存层如何与业务逻辑层一起工作的一些有用建议。 Specifically, should the caching layer handle only cached/cachable objects and pass other functions straight-through to the BLL or should the caching layer almost take the place of the BLL and leave that to just being the bridge between the caching layer and the DAL? 具体地说,缓存层应该处理缓存的/可缓存的对象并直接将其他功能传递给BLL,还是应该使缓存层几乎代替BLL,而仅作为缓存层和DAL之间的桥梁?

A good example of this and the one that has me scratching my head is basket functionality on an ecommerce website. 电子商务网站上的购物篮功能就是一个很好的例子,这让我抓狂。 Pre-caching layer, items were added to cart via the BLL to the DAL. 在预缓存层,通过BLL将商品添加到购物车到DAL。 At the BLL there's lots of logic for checking types of items etc. Should the caching layer now take responsibility for some of this logic or just pull the cached info together and pass it all through to the BLL? 在BLL,有很多检查项目类型等的逻辑。缓存层现在应该负责其中的某些逻辑,还是仅将缓存的信息拉到一起,然后全部传递给BLL?

I'd appreciate anyone's help on this. 我很感谢任何人的帮助。

It all depends on what you are caching. 这完全取决于您要缓存的内容。 If I understood your question correctly, the caching in your scenario take the place of your data source; 如果我正确理解了您的问题,则场景中的缓存将取代您的数据源; it doesn't replace your business logic or other layers. 它不会取代您的业务逻辑或其他层次。 In your shopping basket example, when you put the items in the basket, you cache those items so that you don't have to get them from their permanent storage often. 在您的购物篮示例中,当您将商品放在购物篮中时,您会缓存这些商品,这样就不必经常从它们的永久存储中获取它们。 However, if you have a logic that needs to check the items frequently, then you still do that, but by checking the items in the cached basket. 但是,如果您有一个逻辑需要经常检查项目,那么您仍然可以执行此操作,但是要检查缓存篮子中的项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM