tags:

views:

80

answers:

3

I hear much talk about memcached, but when briefly studied on it, I couldn't understand what advantages I can take instead of using the good old Dictionary<string, object> to cache my data in my applications.

Can someone explain it to me?

+1  A: 

As I understood after reading wikipedia and memcached.org it has at least following features

  • memcached acts like a service to your program, so if your program crash, memcached doesn't
  • it can be distributed amount servers (scalability!)
  • it is cache not just dictionary, so it can delete data if it likes to (no overflow)

similiar concept is not Dictionary<string, object> but HttpContext.Current.Cache, but still it is different

Andrey
+1  A: 

The reason I started looking into it was because our app was load-balanced across multiple servers: if I used memcached, I could use its cache (and some implementations seem to have a session state provider as well) to not only split loads across all servers, but also knock one off the farm for maintenance or deployment while keeping the others intact.

Chris
A: 

It's not that much different from a Dictionary, it just runs on a different server.

You would want to use memcached if you have need your cache to live beyond the lifetime of your ASP.NET application (which could be recycled at any point). Depending on the size and number of items which you need to cache, you can get to the point where there is not enough space on the IIS server. Remember that it has to run the application and cache all of the items.

In some cases creating a cache of items is very expensive for an application. In these applications you will cause significant pain on other services such as a database if IIS needs to be recycled.

When you start to use memcached you need to make considerations for how it will fit with how you use your database (or other backing store). You need to decide whether you are going to only write to memcached and have that event update the content in the database. From an economic standpoint you should probably be thinking about whether you can use memcached to avoid the cost of installing another database server (assuming that costs more to build/maintain in your situation).

BrianLy