本文介绍了读者作家锁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为AppFabric缓存寻找类似于  readerwriterlockslim类的内容。

I'm looking for something similar to the readerwriterlockslim class for the AppFabric caching.

99%访问是对缓存中对象的读访问,并且偶尔我需要更改一个对象。

99% of the access is a read access to the objects in the cache, and occasionally I need to change the an object.

目前我看到只有GetAndLock,未来是否有任何计划支持锁定级别(读/写)? 

Currently I saw that there's only GetAndLock, are there any plans in the future to support a Lock Level (read/write) ? 

Thansk

Shlomi

推荐答案

AppFabric缓存已经支持这种乐观并发控制的机制。

AppFabric Caching already supports a mechanism for this kind of optimistic concurrency control.

你可以使用Put(键,值,版本)API的版本化重载,这将确保只有当Put API看到的版本是它预期的并且没有被另一个put更改时,更新才会成功。读写器锁逻辑可以轻松构建

You can use the versioned overloads of the Put(key,value,version) API, this will ensure that the update succeeds only if the version seen by the Put API is what it anticipates and has not been changed by another put. The reader-writer lock logic easily builds on top of this.

探索API并告诉我们您是否有任何疑惑。

Explore the API and let us know if you have any confusion.


这篇关于读者作家锁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 19:04