WCF with MemoryCaching
-
I need to create a WCF service that's going to do some pretty heavy database querying that I therefore want to cache. (
System.Runtime.Caching
) For performance reasons it should also be multithreaded. If I would setInstance Context Mode
toPerCall
I can't use MemoryCaching since the cache is recreated with every instance. If I would setInstance Context Mode
toSingle
andConcurrency Mode
toMultiple
, Caching would work just fine but I would need to make everything threadsafe. Have I understood everything right? Any better recommendations?Wrong is evil and must be defeated. - Jeff Ello
-
I need to create a WCF service that's going to do some pretty heavy database querying that I therefore want to cache. (
System.Runtime.Caching
) For performance reasons it should also be multithreaded. If I would setInstance Context Mode
toPerCall
I can't use MemoryCaching since the cache is recreated with every instance. If I would setInstance Context Mode
toSingle
andConcurrency Mode
toMultiple
, Caching would work just fine but I would need to make everything threadsafe. Have I understood everything right? Any better recommendations?Wrong is evil and must be defeated. - Jeff Ello
I assume you are talking about using ASP.NET Cache object in WCF services (w/ AspNetCompatibilityMode) but I don't quite get this "can't use MemoryCaching since the cache is recreated with every instance" ASP.NET cache will remain as long as the Application remains (which can be configured not to be re-cycled). Have a look at NCache Express or any other caching framework including memcached.
-
I assume you are talking about using ASP.NET Cache object in WCF services (w/ AspNetCompatibilityMode) but I don't quite get this "can't use MemoryCaching since the cache is recreated with every instance" ASP.NET cache will remain as long as the Application remains (which can be configured not to be re-cycled). Have a look at NCache Express or any other caching framework including memcached.
.Shoaib wrote:
I assume you are talking about using ASP.NET Cache object
No, as I specified I am talking about
System.Runtime.Caching
. The problem with using Asp.Net caching is twofold. First AspNetCompatibilityMode is slow, secondly it only works if WCF service is hosted inside IIS and uses an HTTP-based binding. Which by the way also is slow. I'm aiming to use Net.Tcp binding.Wrong is evil and must be defeated. - Jeff Ello