in a WCF app,i have 80k+ rows in database which rarely change. i want to cache them in memory for faster lookup. i should be able to evict them when needed. I have found some C# libraries for it. some of them use MemoryCache internally while others use ConcurrentDictionary. since both MemoryCache and ConcurrentDictionary are thread-safe, are there any other benefits for which i should choose MemoryCache or vice versa?
Asked
Active
Viewed 593 times
0
-
Can any data rows be changed by external sources, like scheduled console applications? Are there several frontend services sharing the cache? Any scalability requirements? – sisve Jul 28 '14 at 17:11
-
i already have redis for caching. this API will sit on top of redis storing a small subset of redis data that is very frequently accessed. external source can update data in redis. if that happens, API should be able to sync. – nur Jul 28 '14 at 17:18
1 Answers
1
Effectively, they both do what you want - store data in memory.
The difference is that MemoryCache allow you to set cache policy and expiration time which is something you may have to write manually if you were to use dictionary.
If you need to scale this, consider using memcached or redis.

oleksii
- 35,458
- 16
- 93
- 163