APCGC_CBS.Common/CacheHelper.cs

(开头部分) 5KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.SessionState;

namespace APCGC_CBS.Common
{
    public sealed class CacheHelp : IRequiresSessionState
    {
        /// <summary>
        /// 添加Session值
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public static void AddSession(string key, object value)
        {
            if ((HttpContext.Current != null) && (HttpContext.Current.Session != null))
            {
                HttpContext.Current.Session.Add(key, value);
            }
        }

        /// <summary>
        /// 设置当前应用程序指定key的Cache值
        /// </summary>
        /// <param name="key"></param>
        /// <param name="obj"></param>
        public static void SetCache(string key, object obj)
        {
            System.Web.HttpRuntime.Cache[key] = obj;
        }


        /// <summary>
        /// 获得指定Key的Cache值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static object GetCache(string key)
        {
            if (System.Web.HttpRuntime.Cache[key] != null)
            {
                return System.Web.HttpRuntime.Cache[key];
            }
            return null;
        }


        /// <summary>
        /// 获得指定Key的Session值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static object GetSession(string key)
        {
            if ((HttpContext.Current != null) && (HttpContext.Current.Session != null))
后面还有 98 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。