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

namespace Stat.Cache
{
    class WebSite : IWebSite
    {

        #region IWebSite 成员

        public IList<Stat.Model.WebSites> Get(int webid)
        {
            string cName = "Website_" + webid.ToString();
            if (HttpContext.Current.Cache.Get(cName) == null)
            {
                IList<Stat.Model.WebSites> list = BLL.WebSites.GetWebSiteInfo(webid);
                if (list != null && list.Count > 0)
                {
                    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.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
    }
}
