简体   繁体   English

在IIS中用于处理对共享资源的多个请求的设计模式是什么

[英]What is the design pattern to be used to deal with multiple requests to a share resource in IIS

I have a Lucene Index on a central file system. 我在中央文件系统上有一个Lucene索引。 In my IIS application, I have methods to query the index and another to update the index. 在我的IIS应用程序中,我具有查询索引的方法和另一个更新索引的方法。

To update the index, I have to lock the file until the changes are committed. 要更新索引,我必须锁定文件,直到提交更改为止。 My problem in implementing this is choosing the best design pattern to maintain good concurrency. 实现此问题的我的问题是选择最佳设计模式以保持良好的并发性。

Am I best off using a static updater class that uses a lock about a static object? 我最好使用静态更新程序类,该类使用有关静态对象的锁吗? If another request to update the index comes in while the lock is active, will the request 'wait' or will it return an exception? 如果在锁定处于活动状态时出现另一个更新索引的请求,该请求将“等待”还是将返回异常? If it cannot wait, should I implement a thread safe FIFO type object with the series of operations to conduct sequentially? 如果迫不及待,我是否应该通过一系列要顺序执行的操作来实现线程安全的FIFO类型对象?

You should probably update the index as a completely separate operation, in a windows service in some fashion. 您可能应该以某种方式在Windows服务中将索引更新为完全独立的操作。

Is that an option? 那是一个选择吗? Or do you need it consistently 24/7? 还是您始终需要24/7全天候使用? I suspect you probably don't. 我怀疑你可能不会。

Furthermore, even if you do, you could possibly have your own 'cache' of newly added/removed items that you pass through before going to Lucene. 此外,即使您这样做,也可能会拥有自己的“缓存”,以便在进入Lucene之前通过的新添加/删除的项目。

您想要的是一种基于多个作者的读者设计模式的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM