WCF服务器端缓存 [英] WCF Server Side Cache

查看:296
本文介绍了WCF服务器端缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个WCF,它将返回字符串数据.该方法将带有一个参数,并返回数据库中的数据.
如果WCF上的负载很高,那么最好使用一些缓存,以避免一直无休止地进入db.

hotel:该方法将返回最近的项目.因此,该方法应该为所有提供相同时间间隔作为参数的请求返回相同的响应.

如何有效地做到这一点?我读过一些有关Basic Web HTTP Service Caching的文章,但是我不确定这是否是最好的解决方案.

非常感谢.

I''m developing a WCF that will return string data. The method will take a parameter and return with data from a database.
If the load on the WCF is high, it would be great to use some caching, to avoid having to dig in to the db all the time.

hotel: The method will return recent items. So the method should return the same response for all request that provides the same time intervall as a parameter.

How can this be done efficiently? I''ve read a litle about Basic Web HTTP Service Caching, but I''m not sure if this is the best solution.

Thanks a lot.

推荐答案

如果您最关心的是访问数据库,则应查看WCF服务数据层的缓存.如果您使用的是Entity Framework,则可以以此为指导:

实体框架-使用DbContext进行二级缓存 [ ^ ]

如果您使用的是NHibernate,则可以使用以下代码:

http://nhibernate.hibernatingrhinos.com/28/first-and-second- level-caching-in-nhibernate [ ^ ]
If hitting the database is your big concern, you should look at caching at the data layer of your WCF service. If you''re using Entity Framework you can use this as a guide:

Entity Framework - Second Level Caching with DbContext[^]

if you''re using NHibernate you can use this:

http://nhibernate.hibernatingrhinos.com/28/first-and-second-level-caching-in-nhibernate[^]


这篇关于WCF服务器端缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆