using System.Collections.Generic;
using System.Web;
using System.Web.Caching;
namespace Stat.Cache
{
    class Navigate : INavigate
    {
        /// <summary>
        /// 导航条
        /// </summary>
        /// <param name="s">条数</param>
        /// <returns></returns>
        public IList<Stat.Model.Navigate> Get(int s)
        {
            string cName = "Navigate_" + s.ToString();
            if (HttpContext.Current.Cache.Get(cName) == null)
            {
                // 建立缓存依赖项，如果文件发生变化，删除缓存
                string cTxt = @"\CacheTxt\Navigate.txt";
                Methods.CreatFile(HttpContext.Current.Server.MapPath(cTxt));
                CacheDependency dep = new CacheDependency(HttpContext.Current.Server.MapPath(cTxt));

                IList<Stat.Model.Navigate> tep = BLL.Navigate.Get(s, 1);
                if (tep != null)
                {
                    HttpContext.Current.Cache.Insert(cName, tep, dep, System.DateTime.MaxValue, System.TimeSpan.FromDays(1.0), CacheItemPriority.Default, null);

                }
                return tep;
            }
            return (IList<Stat.Model.Navigate>)(HttpContext.Current.Cache.Get(cName));//从缓存中读取
        }
    }
}
