I’m writing a database-backed Directory implementation for Lucene.NET (project page on BitBucket) and I’m a bit at a loss about what to do with locking.
Naturally, locks are essential for reliable indexing and searching, but I’m not sure I’m doing things correctly. More specifically, are locks used just to serialize access to index so that writes are happening sequentially or is there something more complex to it?
For example, is this
insert into [Lock] (LockName) values (@lockName)
and then checking if this row is still there enough for this implementation to be reliable?
Yes it is enough. See this example
In case, you haven’t already known these Lucene Directory implementations:
Azure Library for Lucene.Net
Lucene Oracle Data Cartridge