Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Minimal-locking thread-safe hashtable?

Are there any available implementations of a Hashtable that provide thread safety with minimal locking in .NET? Or in another language that can be ported to .NET?

We're looking for something in between using a BCL Dictionary<,> class with lock() and a distributed caching application like memcached or Velocity.

The intended use is for a cache with thousands of readers reading out immutable values based on keys (either numbers or guids, we haven't decided which yet). There will be far less writers, possibly only one.

like image 672
Samuel Neff Avatar asked Jan 21 '10 16:01

Samuel Neff


1 Answers

Starting in .Net 4.0 there is ConcurrentDictionary. This is a hashtable style structure meant for high performance use between multiple threads.

Details on it's use and implementation can be found here:

  • http://blogs.msdn.com/pfxteam/archive/2010/01/08/9945809.aspx
like image 193
JaredPar Avatar answered Sep 23 '22 15:09

JaredPar