Exemplo n.º 1
0
        private Document GetCacheEntry(string key, bool ignoreRemovalQueue = false)
        {
            if (!ignoreRemovalQueue && _removalCache.Contains(key))
            {
                return(null);
            }

            var scopedSearcher = _indexController.GetScopedLuceneSearcher();

            var query = new BooleanQuery();

            query.Add(new BooleanClause(new TermQuery(new Term("CacheKey", key)), BooleanClause.Occur.MUST));
            var topDocs = scopedSearcher.Search(query, 1);
            var topDoc  = topDocs.ScoreDocs.Any() ? topDocs.ScoreDocs[0] : null;

            if (topDoc != null)
            {
                return(scopedSearcher.Doc(topDoc.doc));
            }
            return(null);
        }