Ejemplo n.º 1
0
        protected static SearchDictDirCache GetByDictDir(string key)
        {
            SearchDictDirCache cache = new SearchDictDirCache();

            cache.key       = key;
            cache.cacheTime = DateTime.Now;

            //  获取
            EnginesElement config = SearchEngineConfig.Instance.Engines[key];

            System.IO.DirectoryInfo mydir = new System.IO.DirectoryInfo(config.IndexDir);
            cache.dictDir = mydir.GetDirectories().LastOrDefault().FullName;

            return(cache);
        }
Ejemplo n.º 2
0
        public static SearchDictDirCache Get(string key)
        {
            SearchDictDirCache info = searchDictDirCache.Get(key, GetByDictDir);

            if (info == null)
            {
                return(null);
            }
            if (info.cacheTime.AddHours(SearchEngineConfig.Instance.CacheTime) < DateTime.Now)
            {
                searchDictDirCache.Remove(key);
                info = searchDictDirCache.Get(key, GetByDictDir);
            }
            return(info);
        }