最小锁定线程安全哈希表? [英] Minimal-locking thread-safe hashtable?

查看:43
本文介绍了最小锁定线程安全哈希表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有Hashtable的可用实现,这些实现在.NET中提供线程安全性并具有最小限度的锁定?还是可以移植到.NET的另一种语言?

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?

我们正在寻找一种使用带有lock()的BCL字典<,>类和分布式缓存应用程序(例如memcached或Velocity)之间的东西.

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

预期用途是用于具有数千个读取器的缓存,该读取器基于键(数字或guid,我们尚未确定哪个键)读出不可变的值.作家将大大减少,也许只有一个.

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.

推荐答案

从.Net 4.0开始,有

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:

这篇关于最小锁定线程安全哈希表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆