I have a WCF web service in .Net 4.0.

I am calling another web service from it and that is sending me an XML object (arond 50 KB) as response.

The response object is not likely to get changed frequently. So I should be choosing a caching technique to make one call less each time and it will be faster too.

I read that there are many .Net caching techniques available..some are suitable for WCF service also.

Please guide me on which type caching technique I should go for?

有帮助吗?

解决方案

Since you have only a single service that needs to access this cache and it isn;t that big a deal if the cache gets reset every couple hours, you can keep things really simple.

The simplest solution is to use the in-process memory cache. Its basically a dictionary in memory that you can store whatever values in, but it also takes care of not taking up too much memory and expiring entries if they get too old.

Here is a good writeup with an example of how to use it.

其他提示

As caching is happening on your own server, you would be using deserialized xml into some class object. I think the best thing would be to use post sharp in your case. See this: http://www.sharpcrafters.com/postsharp/download

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top