I have a Lucene Index on a central file system. In my IIS application, I have methods to query the index and another to update the index.
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?
What you want is something based on the one reader many writers design pattern.
You should probably update the index as a completely separate operation, in a windows service in some fashion.
Is that an option? Or do you need it consistently 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.