views:

99

answers:

3

I'm planning to develop a web service, i need to use in memory cache, what different caching frameworks are available out there for .NET, i have used Microsoft Enterprise Library Cache block and also evaluated NCache for distributed environment.

My core requirement is reliability with Cached data, i was thinking of using Enterprise Lib Cache block DB data store for persistence in case worker process get restarted.

Any options??

+3  A: 

I have experience using Microsoft's Enterprise Library Cache Block and it worked fine for me. The EntLib configuration can be a bit verbose at times but it gets the job done. Is there a particular reason you are looking for something else?

Andrew Hare
i'm not too sure about the reliability factor, and never used it with DB as data store.
BT
we use it in a production environment, it has been stable for us with a DB as the datastore. There is also, an in memory setting... backingStoreName="Null Storage"
Lucas B
+1  A: 

A couple come to mind:

1) Memcached

2) Enterprise Library Caching Application Block

Lucas B
Can we use memcached in .NET?
BT
Yes you can, memcached is a server app and you need to download one of the .net clients for it.
Robert C. Barth
+2  A: 

Your cache is a volatile data store, you should write your software so that it EXPECTS that the cache is unavailable. e.g.

public DtoThing GetSomeData(string parameters)
{
   if (<check cache for data> == <not there>)
     return <get data from persistent store>
   else
     return <get data from cache>
}

If you use a database as a backing store for the cache, you've basically just traded away all the benefits of using a cache. When you say the cache needs to be reliable, are you saying that the updates need to be consistent or that the data needs to always be in the cache? If the former, it's easy to make sure that happens as long as you write your software in such a way that there is only ever one path to update the data, and then that path can invalidate the cache upon successfully performing its write to the persistent data store.

Robert C. Barth
Yes we can design an application to handle what you suggested above, but it's true for a case when you are using cache just for storing the reference data. What if you want to store some important data to cache that always needs to be there?
BT
Again, you don't access the cache directly, you access the cached data through a proper business logic layer component, which abstracts the checking of in-memory cache and persistent data store. Doing it any other way WILL fail.
Robert C. Barth