views:

30

answers:

2

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?

A: 

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.

Noon Silk
So even if it is a windows service, it still needs to be able to handle simultaneous requests. I'm wondering what the best way to handle that is.
Matt
What I mean is the server will just do the updating out of hours of typical website usage; so you'll reduce the impact on users.
Noon Silk
Nah, it will occur live
Matt
What will occur live? You need the updates to the index live? See my other comment.
Noon Silk
A: 

What you want is something based on the one reader many writers design pattern.

Matt H