Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

1 solution

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[^]
 
Share this answer
 
Comments
niraj.kumar108 8-Nov-12 8:22am    
Thanks for Reply.
i am not using Entity Framework or NHibernate.i have simple wcf service. My service method will return same types of response for same equest in same day next day response may be chenged. if same types of request getting by any user i do not want to hit on database server.
jim lahey 8-Nov-12 8:28am    
Then your question is not clear. You specifically mentioned not wanting to hit the database all the time. If you are using a database then there will be some sort of abstraction layer giving you access to said database, which is where I suggest you do the caching.
niraj.kumar108 8-Nov-12 8:52am    
Sorry for this confusion, actually my english is not good.

actually since this content does(Data) not change much, why not export it as xml file, put it on the web server and have the list bind to a xmldatasource? Please suggest me this is better ....

then when there is a change in the categories, just update the xml datasource?
jim lahey 8-Nov-12 9:02am    
that sounds a lot more complicated - you'd have to manage all the state yourself. Using a caching provider at the data layer would save you that work.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900