public override List<AspnetUserExtInfo> GetList()
        {
            string key = _cacheKeyPrefix + "_UserExtList";

            List<AspnetUserExtInfo> list = (List<AspnetUserExtInfo>)_cache.GetData(key);

            if (list == null)
            {
                list = new List<AspnetUserExtInfo>();
                string spname = "aspnet_UserExtentInfo_GetList";
                Database db = DatabaseFactory.CreateDatabase(_connectionStringName);
                DbCommand comm = db.GetStoredProcCommand(spname);
                db.AddParameter(comm, "@ReturnValue", DbType.Int32, ParameterDirection.ReturnValue,
                  String.Empty, DataRowVersion.Default, null);
                db.AddInParameter(comm, "@ApplicationName", DbType.String, _applicationName);
                DataSet ds = db.ExecuteDataSet(comm);
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    list.Add(BuildUserExtInfo(row));
                }
                SlidingTime slidingExpired = new SlidingTime(new TimeSpan(0, 2, 0, 0, 0));
                ICacheItemExpiration[] expiredList = { slidingExpired };

                _cache.Add(key, list, CacheItemPriority.Normal, null, expiredList);
            }
            return list;
        }
Exemplo n.º 2
0
 private static void addCache(string key, object value)
 {
     if (_config.SessionTimeOut > 0)
     {
         SlidingTime _objSlidingTime = new SlidingTime(TimeSpan.FromMinutes(_config.SessionTimeOut));
         cacheManager.Add(key, value, CacheItemPriority.None, null, _objSlidingTime);
     }
     else
     {
         cacheManager.Add(key, value);
     }
 }
		private ICacheItemExpiration[] GetCacheExpirations()
		{
			ICacheItemExpiration[] cachingExpirations = new ICacheItemExpiration[2];
			cachingExpirations[0] = new AbsoluteTime(new TimeSpan(0, 0, ConvertExpirationTimeToSeconds(absoluteExpiration)));
			cachingExpirations[1] = new SlidingTime(new TimeSpan(0, 0, ConvertExpirationTimeToSeconds(slidingExpiration)));
			return cachingExpirations;
		}
Exemplo n.º 4
0
 public SlidingTime(TimeSpan slidingExpiration)
 {
     expiration = new EntCaching.SlidingTime(slidingExpiration);
 }
        /// <summary>
        /// ��ò˵���Ȩ��֤����
        /// </summary>
        /// <returns></returns>
        public override Dictionary<string, string> GetAllMenuRoleMaps()
        {
            string key = _cacheKeyPrefix + "_MenuRoleMaps";
            string apppath = System.Web.HttpContext.Current.Request.ApplicationPath;
            if (!apppath.EndsWith("/"))
                apppath += "/";

            ICacheManager cache = CacheFactory.GetCacheManager();
            Dictionary<string, string> maps = (Dictionary<string, string>)cache.GetData(key);

            if (maps == null)
            {
                maps = new Dictionary<string, string>();

                DataTable table = GetMenusForValidate();
                if (table.Rows.Count > 0)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        string baseurl = row["baseurl"].ToString().Trim().ToLower();
                        if (!_isAppRootPath)
                            baseurl = baseurl.Replace("~/",apppath);
                        maps.Add(baseurl, row["roles"].ToString());

                    }
                }
                SlidingTime slidingExpired = new SlidingTime(new TimeSpan(0, 2, 0, 0, 0));
                ICacheItemExpiration[] expiredList = { slidingExpired };
                if (!cachekeys.Contains(key))
                {
                    cachekeys.Add(key);
                }
                cache.Add(key, maps, CacheItemPriority.Normal, null, expiredList);
            }
            return maps;
        }
        protected override Hashtable LoadDataFromStore()
        {
            Hashtable cacheItems = new Hashtable();
            String searchString = String.Concat("*", _dataExtension);
            String[] cacheFiles = Directory.GetFiles(_filePath, searchString, SearchOption.TopDirectoryOnly);

            foreach(String cacheFile in cacheFiles)
            {
                String infoName = String.Concat(Path.GetFileNameWithoutExtension(cacheFile), _infoExtension);
                String infoPath = Path.Combine(_filePath, infoName);

                String[] infoData = File.ReadAllLines(infoPath);
                String itemKey = infoData[0];
                DateTime lastAccessed = DateTime.Parse(infoData[1]);

                TimeSpan slidingDuration;
                SlidingTime slidingTime = null;
                if(TimeSpan.TryParse(infoData[2], out slidingDuration))
                    slidingTime = new SlidingTime(slidingDuration);

                Byte[] itemBytes = File.ReadAllBytes(cacheFile);
                Object itemValue = SerializationUtility.ToObject(itemBytes);

                CacheItem item;
                if(slidingTime != null)
                    item = new CacheItem(lastAccessed, itemKey, itemValue, CacheItemPriority.Normal, null, slidingTime);
                else
                    item = new CacheItem(lastAccessed, itemKey, itemValue, CacheItemPriority.Normal, null);

                cacheItems.Add(itemKey, item);
            }

            return cacheItems;
        }
Exemplo n.º 7
0
 private ICacheItemExpiration[] GetCacheExpirations()
 {
     CachingStoreProviderData cacheStorageProviderData = GetCacheStorageProviderData();
     ICacheItemExpiration[] cachingExpirations = new ICacheItemExpiration[2];
     cachingExpirations[0] = new AbsoluteTime(new TimeSpan(0, 0, ConvertExpirationTimeToSeconds(cacheStorageProviderData.AbsoluteExpiration)));
     cachingExpirations[1] = new SlidingTime(new TimeSpan(0, 0, ConvertExpirationTimeToSeconds(cacheStorageProviderData.SlidingExpiration)));
     return cachingExpirations;
 }