public void TestSearchInCacheMatch()
        {
            var user = 1;
            var query = "text:a";
            var results = new List<string>() { "1", "2" };

            var queryCache = new QueryCache();
            queryCache.Add(user, query, results);
            var res = queryCache.SearchInCache(user, query);

            Assert.AreEqual(results, res);
            Assert.AreNotEqual(results, new List<string>() {"3", "4"});
        }
        public void TestSearchInCacheNotMatch()
        {
            var user = 1;
            var query1 = "text:a";
            var query2 = "text:b";
            var results = new List<string>() { "1", "2" };

            var queryCache = new QueryCache();
            queryCache.Add(user, query1, results);

            var res = queryCache.SearchInCache(user, query2);

            Assert.IsNull(res);
        }
        public void TestDeleteOldQueries()
        {
            var user = 1;
            var queries = new List<string>() { "text:a", "text:b", "text:c", "text:d" };
            var results = new List<string>() { "1", "2" };

            var queryCache = new QueryCache() { LIMIT = 3, VALID_TIME_SECONDS = 5 };
            foreach (var query in queries)
            {
                queryCache.Add(user, query, results);
                Thread.Sleep(500);
            }
            Assert.IsNull(queryCache.SearchInCache(user, "text:a"));
            var res = queryCache.SearchInCache(user, "text:b");
            Assert.IsNotNull(res);
            Assert.AreEqual(results, res);
        }
 public NivelDocumentalSearcher(string orderBy, string defaultField, Cache.QueryCache c)
     : base(FSDirectory.Open(Util.NivelDocumentalPath), orderBy, defaultField, new InstancePerFieldAnalyzerWrapper().instancePerFieldAnalyzerWrapper)
 {
     this.queryCacher = c;
 }
 public NivelDocumentalSearcher(string orderBy, string defaultField, Cache.QueryCache c)
     : base(FSDirectory.Open(Util.NivelDocumentalPath), orderBy, defaultField, new InstancePerFieldAnalyzerWrapper().instancePerFieldAnalyzerWrapper) {
    this.queryCacher = c;
 }