Beispiel #1
0
 public void Refresh()
 {
     _isLock = true;
     while (_lock.TryEnter())
     {
     }
     try
     {
         if (_cache == null)
         {
             _cache = _dic.Values.OrderByDescending(v => v.SearchCount).ToPerfectList();
         }
         else
         {
             var list = new List <InstrumentNode>(SettingCache.LuceneHotWord);
             foreach (var v in _cache)
             {
                 Instrumentation.Revoke(v);
                 if (_dic.ContainsKey(v.Key))
                 {
                     v.SearchCount += _dic[v.Key].SearchCount;
                     _dic.Remove(v.Key);
                 }
             }
             _cache = _dic.Values.Union(_cache).OrderByDescending(v => v.SearchCount).Distinct().Take(SettingCache.LuceneHotWord).ToPerfectList();
         }
         PublishCache();
         _dic.Clear();
         SerizlizerUtils <List <InstrumentNode> > .SerializeLastCache(_cache, _bufferName);
     }
     finally
     {
         _isLock = false;
         _lock.Exit();
     }
 }
Beispiel #2
0
 /// <summary>
 /// 刷新扩展,保存内存数据到本地
 /// </summary>
 public virtual void RefreshExtension()
 {
     SerizlizerUtils<T>.SerializeLastCache(_cache, BufferName);
 }