Ejemplo n.º 1
0
        internal static void SaveResultsAndClearLucenePool(string luceneIndex)
        {
            ReadWriteLock.TryEnterWriteLock(IndexConstants.ReadWriteLockTimeOutMilliseconds);

            try
            {
                if (IndexReaderPool.TryRemove(luceneIndex, out var indexReader))
                {
                    indexReader.Dispose();
                }

                if (IndexWritesPool.TryRemove(luceneIndex, out var indexWriter))
                {
                    indexWriter.Dispose();
                }

                IndexSearcherPool.TryRemove(luceneIndex, out _);

                IndexGotChanged.AddOrUpdate(luceneIndex, u => 0, (u, v) => 0);
            }
            finally
            {
                ReadWriteLock.ExitWriteLock();
            }
        }
Ejemplo n.º 2
0
        internal static void SaveResults(string luceneIndex, bool forceCommitChanges)
        {
            ReadWriteLock.TryEnterWriteLock(IndexConstants.ReadWriteLockTimeOutMilliseconds);

            try
            {
                if ((forceCommitChanges || shouldCommitChanges) && IndexWritesPool.TryGetValue(luceneIndex, out var indexWriter))
                {
                    indexWriter.Commit();
                    shouldCommitChanges = false;
                }
            }
            finally
            {
                ReadWriteLock.ExitWriteLock();
            }
        }