Search code examples
.netwcfcachingappfabricncache

Cache Implementation for .NET


We are planning to implement cache management for a webservice. These are the two options we have in list for Caching.

  • NCache
  • AppFabric

Now we are looking for a way to reset the data in cache and this is what we got so far: We are going to store Accounts and Categories as of now to Cache. This values will be changing from different applications but in same table in same database.

  1. Have a lookup table for each type of data/item(Account,Category) we are going to store in cache.
  2. Whenever there is a change for the values of mentioned type, add a entry to one table(dbo.ResetCache).
  3. Have a windows service checking this table and reset the Cache if there is an entry.

Let me know if you need more clarity on any points and I would like to get your suggestion for this implementation.


Solution

  • I can comment on this in regards to NCache since I have used it for a few years now. Based on my experience NCache has this as ability built into and is called "Database Dependency". You can set up dependency between the cache items and database table entries so that if any data from within the database table changes, the cache item gets removed or updated automatically in NCache.

    You will not be required to set up any "ResetCache" table and then create any windows service that would make all of this happen as it is already a built in feature of NCache. NCache has polling based dependency and DB dependency (SQL/Oracle) which you can read more about from the official links.

    Polling based dependency : http://www.alachisoft.com/resources/docs/ncache/prog-guide/polling-based-dependency.html sql dependency: http://www.alachisoft.com/resources/docs/ncache/prog-guide/sql-dependency.html Oracle dependency: http://www.alachisoft.com/resources/docs/ncache/prog-guide/oracle-dependency.html

    I hope this helps.