//此枚举是自己定义的.可根据需要定义不同的枚举 //加个枚举目的是实现“一键多值”存储方法,事实上Cache中是存放了多个变量的,只不过被这个类封装了, //程序员感到就好像是“一键一值”. 这样做目的是可以简化开发操作,否则程序员要存储几个变量就得定义几个Identify. public static bool InsertCommonInf(string strIdentify, StorageInfType enumInfType, object objValue) { if (strIdentify != null && strIdentify != "" && strIdentify.Length != 0 && objValue != null) { //RemoveCommonInf(strIdentify,enumInfType); //建立回调委托的一个实例 CacheItemRemovedCallback callBack = new CacheItemRemovedCallback(onRemove); if (enumInfType == StorageInfType.UserInf) { //以用户UserID+信息标志(StorageInfType枚举),将userInfo存入Cache HttpContext.Current.Cache.Insert(strIdentify + StorageInfType.UserInf.ToString(), objValue, null, System.DateTime.Now.AddSeconds(18000), //单位秒 System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Default, callBack); } if (enumInfType == StorageInfType.PageInf) { //以用户UserID+信息标志(StorageInfType枚举),将PageInfo存入Cache HttpContext.Current.Cache.Insert(strIdentify + StorageInfType.PageInf.ToString(), objValue, null, System.DateTime.Now.AddSeconds(18000), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Default, callBack); } if (enumInfType == StorageInfType.SysInf) { //以用户UserID+信息标志(StorageInfType枚举),将SysInfo存入Cache HttpContext.Current.Cache.Insert(strIdentify + StorageInfType.SysInf.ToString(), objValue, null, System.DateTime.Now.AddSeconds(18000), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Default, callBack); } return true; } return false; }
//此枚举是自己定义的.可根据需要定义不同的枚举 //加个枚举目的是实现“一键多值”存储方法,事实上Cache中是存放了多个变量的,只不过被这个类封装了, //程序员感到就好像是“一键一值”. 这样做目的是可以简化开发操作,否则程序员要存储几个变量就得定义几个Identify. public static bool InsertCommonInf(string strIdentify, StorageInfType enumInfType, object objValue) { if (string.IsNullOrEmpty(strIdentify) || strIdentify.Length == 0 || objValue == null) { return(false); } //RemoveCommonInf(strIdentify,enumInfType); //建立回调委托的一个实例 var callBack = new CacheItemRemovedCallback(OnRemove); if (enumInfType == StorageInfType.UserInf) { //以用户UserID+信息标志(StorageInfType枚举),将userInfo存入Cache HttpContext.Current.Cache.Insert(strIdentify + StorageInfType.UserInf.ToString(), objValue, null, System.DateTime.Now.AddSeconds(18000), //单位秒 System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Default, callBack); } if (enumInfType == StorageInfType.PageInf) { //以用户UserID+信息标志(StorageInfType枚举),将PageInfo存入Cache HttpContext.Current.Cache.Insert(strIdentify + StorageInfType.PageInf.ToString(), objValue, null, System.DateTime.Now.AddSeconds(18000), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Default, callBack); } if (enumInfType == StorageInfType.SysInf) { //以用户UserID+信息标志(StorageInfType枚举),将SysInfo存入Cache HttpContext.Current.Cache.Insert(strIdentify + StorageInfType.SysInf.ToString(), objValue, null, System.DateTime.Now.AddSeconds(18000), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Default, callBack); } return(true); }
//此枚举是自己定义的.可根据需要定义不同的枚举 //加个枚举目的是实现“一键多值”存储方法,事实上Cache中是存放了多个变量的,只不过被这个类封装了, //程序员感到就好像是“一键一值”. 这样做目的是可以简化开发操作,否则程序员要存储几个变量就得定义几个Identify. public static bool InsertCommonInf(string strIdentify, StorageInfType enumInfType, object objValue) { if (strIdentify != null && strIdentify != "" && strIdentify.Length != 0 && objValue != null) { //RemoveCommonInf(strIdentify,enumInfType); //建立回调委托的一个实例 CacheItemRemovedCallback callBack = new CacheItemRemovedCallback(onRemove); if (enumInfType == StorageInfType.UserInf) { //以用户UserID+信息标志(StorageInfType枚举),将userInfo存入Cache HttpContext.Current.Cache.Insert(strIdentify + StorageInfType.UserInf.ToString(), objValue, null, System.DateTime.Now.AddSeconds(18000), //单位秒 System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Default, callBack); } if (enumInfType == StorageInfType.PageInf) { //以用户UserID+信息标志(StorageInfType枚举),将PageInfo存入Cache HttpContext.Current.Cache.Insert(strIdentify + StorageInfType.PageInf.ToString(), objValue, null, System.DateTime.Now.AddSeconds(18000), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Default, callBack); } if (enumInfType == StorageInfType.SysInf) { //以用户UserID+信息标志(StorageInfType枚举),将SysInfo存入Cache HttpContext.Current.Cache.Insert(strIdentify + StorageInfType.SysInf.ToString(), objValue, null, System.DateTime.Now.AddSeconds(18000), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Default, callBack); } return(true); } return(false); }