Hei,
I have a WCF service hosted in IIS and want to return the data which is reside in the cache of IIS (HttpContext.Current.Cache) What is the most appropriate choice of type this service should return?
Thanks
Hei,
I have a WCF service hosted in IIS and want to return the data which is reside in the cache of IIS (HttpContext.Current.Cache) What is the most appropriate choice of type this service should return?
Thanks
whatever type you stored in the cache of course...it should be serializable though
If I were you, I would not rely on the fact that the service is hosted in IIS. What if you wanted to host your WCF service with some other technology? I think you should check out memcached which is a much more general caching solution, and it works fine with .NET.
Anyway, if you really want to use the IIS cache, use System.Web.HttpRuntime.Cache instead of HttpContext.Current.Cache as the HttpContext is not always available.
Also, as cruizer said, the actual type of your objects is totally irrelevant as long as they are serializable (that is, the classes are decorated with the [Serializable()] attribute). The IIS cache itself does not require serializable objects but WCF does.
You serialize your objects in order to transport them, but there's no need to cache serializable objects.
Your service calls your business logic in order to process the requests but what gets over the wire should not be your business objects but your service's data contracts.
Wrap your cache API and decouple it from the HttpRuntime Cache. As DrJokepu said, access asp.net cache through HttpRuntime.Cache if you choose so.