Am using Lucene API in a .net web application. I want to use the same instance of Indexsearcher for all the requests.Hence am storing indexsearcher instance in http cache.<
First of all it's not safe at all, it should be:
var searcher = (IndexSearcher)HttpRuntime.Cache["IndexSearcher"]; if(searcher == null) { searcher = new IndexSearcher(jobIndexFolderPath); HttpRuntime.Cache["IndexSearcher"] = searcher; }
In your code cache can expire between check and assignment