English 中文(简体)
A. 高度并行的系统的切入
原标题:Cache access in highly concurrent systems

附录一有两条深线(Thread1, Thread2),即线杆接近特定物体的海滩,如以下代码:

    Dim expensiveToGetData = Cache("ExpensiveDataKey")

    If ExpensiveToGetData is nothing then
 because the cache has expired

ExpensiveToGetData = LoadExpensiveDataFromDataSource()
       Cache("ExpensiveDataKey") = ExpensiveToGetData
    end If

    ProcessExpensiveData(ExpensiveToGetData)

www.un.org/Depts/DGACM/index_spanish.htm 这两条路面都有可能装上海滩,因为它们都要求从没有/未见的海滩上获得数据? 我对当地机器进行了一些测试,看来这些藏匿点的负荷不止一次。 这是一种正常模式吗?

最佳回答

是的,使用该法典,两个不同的要求肯定可能不会从Cache获得,因此,这两个要求都能够重载数据。 如果你想避免这种情况,就必须使数据获取工作的整体运作同步进行。

实现同步准入的一个途径是使用类似于:

Dim expensiveToGetData = Cache("ExpensiveDataKey")

If ExpensiveToGetData is nothing then
    SyncLock yourLockObject /* YourLockObject should be a Shared object. */
        expensiveToGetData = Cache("ExpensiveDataKey")
        If expensiveToGetData Is Nothing Then
            ExpensiveToGetData = LoadExpensiveDataFromDataSource()
            Cache("ExpensiveDataKey") = ExpensiveToGetData
        End If
    End SyncLock
end If

ProcessExpensiveData(ExpensiveToGetData)

检查我们是否在获得数据之前掌握数据的想法是避免在高负荷环境下过度锁定。 如果没有,我们需要在24小时之内再次检查,因为另一条路边可能在我们获得这条锁时冲淡数据。

问题回答

是的,这是可能的,它不是理想的模式。 作为一种快速固定装置,你可以在海滩上设置一个速效锁,但理想的设计是,将海滩作为中间人装载昂贵的数据。 这一设计模式远比我刚才提到的情况要多得多,但应该让你开始。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签