开发者

is this good implementation of Multithreaded Caching in .Net?

While implementing Multithreaded Cache, i found this article on MSDN.

http://msdn.microsoft.com/en-us/library/system.threading.readerwriterlockslim.aspx

This is for windows appliation using framework 4.0. My main concern is Thread Safety. Currently i am using MemoryCache and i know it is no开发者_Go百科t Thread Safe. So is the provided implementation a better way to implement Multithreaded Caching?

Please advice.


I don't quite see the relation between a ReaderWriterLockSlim and caching. This class is used to synchronize the access to a shared resource in a multithreaded application. For implementing data caching I would recommend you taking a look at the System.Runtime.Caching namespace.


Currently i am using MemoryCache and i know it is not Thread Safe.

MemoryCache is thread-safe - look at the Thread Safety section in the MSDN documentation.

Of course the items you put into MemoryCache may not be thread-safe, which is another story. In many cases MemoryCache is used to store immutable elements, which will be thread-safe.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜