Esempio n. 1
0
        internal void RegisterQueryResult(int transaction_id, FanoutQueryMessageReader request, AggregationObject aggregation_obj)
        {
            if (aggregation_obj.results.Count == 0)
            {
                Log.WriteLine(LogLevel.Debug, "QueryResultCache: ignoring empty query result, transaction id = {0}.", transaction_id);
                return;
            }

            QueryResultCacheEntry entry = new QueryResultCacheEntry(transaction_id, aggregation_obj);
            string key_query            = GetQueryResultCacheRequestKey(request);
            string key_trans            = GetQueryResultCacheTransactionKey(entry.transaction_id);

            m_memory_cache.Set(key_query, entry, m_cache_policy);
            m_memory_cache.Set(key_trans, entry, m_cache_policy);
        }
Esempio n. 2
0
        /// <returns>null if no cached query result is found.</returns>
        internal AggregationObject GetCachedQueryResult(FanoutQueryMessageReader query)
        {
            string key = GetQueryResultCacheRequestKey(query);
            QueryResultCacheEntry entry = (QueryResultCacheEntry)m_memory_cache.Get(key);

            if (entry == null)
            {
                return(null);
            }
            int result_cnt = entry.aggregation_obj.results.Count;

            if (result_cnt < FanoutSearchModule.MinimalRequiredResultCount(query))
            {
                return(null);
            }

            Log.WriteLine(LogLevel.Debug, "QueryResultCache: Cache hit.");

            return(entry.aggregation_obj);
        }