DotBBS.Common/CacheUtil.cs

(开头部分) 4KB

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

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Data;
using System.Web.Caching;
using System.Collections;
using System.Text.RegularExpressions;

//============================================================================
// 官方支持:DotBBS.Net   作者:吸铁石团队(水煮鱼)
//============================================================================
namespace DotBBS.Common
{
    /// <summary>
    /// 缓存常用操作
    /// </summary>
    public class CacheUtil
    {
        public CacheUtil()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }

        /// <summary>
        /// 增加一个缓存对象
        /// </summary>
        /// <param name="strKey">键</param>
        /// <param name="valueObj">值</param>
        /// <param name="duration">以秒为单位</param>
        /// <returns></returns>
        public static bool Insert(string strKey, object valueObj, double durationSecond)
        {
            if (strKey != null && strKey.Length != 0 && valueObj != null)
            {
                //建立回调委托的一个实例

                CacheItemRemovedCallback callBack = new CacheItemRemovedCallback(onRemove);
                HttpContext.Current.Cache.Insert(strKey, valueObj, null,DateTime.Now.AddSeconds(durationSecond),System.Web.Caching.Cache.NoSlidingExpiration,
                System.Web.Caching.CacheItemPriority.Default,
                callBack);
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 判断缓存对象是否存在
        /// </summary>
        /// <param name="strKey"></param>
        /// <returns></returns>
        public static bool IsExist(string strKey)
        {
            return HttpContext.Current.Cache[strKey] != null;
        }
后面还有 86 行代码,购买后查看完整代码

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

AI 解读 AI

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

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