Caching List of Objects

Possible duplicate:
Performance system.runtime.caching

I need to cache a list of objects (less than 50 objects with 10-20 fields), the caching method of which mehod caches best.

EnterpriseLibrary Caching or system.runtime.caching

+4
source share
1 answer

Given that you have a relatively small number of objects, I would recommend using system.runtime.caching so that you can avoid the overhead of using EnterpriseLibrary. You can also consider creating a ConcurrenctDictionary to store your cached objects - especially if you want more control over the lifetime of objects (expiration policy, etc.).

If you were building a web application, I would recommend using System.Web.Caching.Cache rather than System.Runtime.Caching.MemoryCache . We had problems with System.Runtime.Caching.MemoryCache , see the following SO article for details: -

+1
source

All Articles