using System.Collections.Generic;
using System.Web;

namespace Stat.Cache
{
    class WebSite : IWebSite
    {

        #region IWebSite 成员

        public Stat.Model.WebSites Get(int webid)
        {
            string cName = "Website_" + webid.ToString();
            if (HttpContext.Current.Cache.Get(cName) == null)
            {
                Stat.Model.WebSites siteModel = BLL.WebSites.GetWebSiteInfo(webid);
                if (siteModel != null)
                {
                    HttpContext.Current.Cache.Insert(cName, siteModel, null, System.DateTime.MaxValue, System.TimeSpan.FromHours(1.0), System.Web.Caching.CacheItemPriority.Low, null);
                }
                return siteModel;
            }
            return (Stat.Model.WebSites)HttpContext.Current.Cache.Get(cName);
        }

        #endregion

        #region IWebSite 成员


        public IList<Stat.Model.WebsiteStructure> GetRuleList(int webID)
        {
            string cName = "WebsiteStructure_" + webID.ToString();
            if (HttpContext.Current.Cache.Get(cName) == null)
            {
                IList<Stat.Model.WebsiteStructure> list = BLL.WebsiteStructure.GetRuleList(webID);
                HttpContext.Current.Cache.Insert(cName, list, null, System.DateTime.MaxValue, System.TimeSpan.FromHours(1.0), System.Web.Caching.CacheItemPriority.Low, null);

                return list;
            }
            return (IList<Stat.Model.WebsiteStructure>)HttpContext.Current.Cache.Get(cName);
        }

        #endregion
    }
}
