微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

分布式sql server缓存中的执行超时已过期?

如何解决分布式sql server缓存中的执行超时已过期?

“执行超时已过期。在操作完成之前超时时间已过,或者服务器没有响应。”在分布式sql server缓存中

我在控制器中调用方法

 public async Task<IEnumerable<normalDeposit_DepositDetails>> GetAllnormalDeposit_DepositDetails_Async()
    {
        if (IsCacheEnable == true)
        {
            IEnumerable<normalDeposit_DepositDetails> normalDeposit_DepositDetails_AllList;
            var KeyHere = KeyCache.GenCacheKey(CacheKeyList.normalDeposit_DepositDetails_CacheSecurityKeyString,SecurityKey);
            var GetCachehere = await distributedCache.GetStringAsync(KeyHere);
            if (string.IsNullOrEmpty(GetCachehere))
            {
                context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
                normalDeposit_DepositDetails_AllList = await context.normalDeposit_DepositDetails.AsNoTracking().ToListAsync();


                distributedCacheEntryOptions options = new distributedCacheEntryOptions();
                options.AbsoluteExpiration = DateTime.Now.AddHours(12);
                options.SlidingExpiration = TimeSpan.FromMinutes(30);
                var Value = JsonConvert.SerializeObject(normalDeposit_DepositDetails_AllList);
               await distributedCache.SetStringAsync(KeyHere,Value,options);
                return normalDeposit_DepositDetails_AllList;
            }
            else
            {
                return JsonConvert.DeserializeObject<IEnumerable<normalDeposit_DepositDetails>>(GetCachehere);
            }
        }
        else
        {
            IEnumerable<normalDeposit_DepositDetails> normalDeposit_DepositDetails_AllList;
            context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
            normalDeposit_DepositDetails_AllList = await context.normalDeposit_DepositDetails.AsNoTracking().ToListAsync();
            return normalDeposit_DepositDetails_AllList;
        }
    }

我的控制器方法

    [AllowAnonymous]
    [HttpPost]
    public async Task<IActionResult> GetDataHere()
    {
        var ItemsHere = await normalDeposit_DepositDetailsInterface.GetAllnormalDeposit_DepositDetails_Async();
        decimal normalDeposit_Deposit_AfterDeposit = ItemsHere.Where(a => a.Status == true ).Sum(s => s.Amount);

        return View("Index");
    }

App.json 方法

  "ConnectionStrings": {
    "ConnectionVar": "Server=DESKTOP-IACJQY;Database=$aZ1*,z.ahbz.@!78z)c;User Id=*&zkaUI190%$User{]z!Z,a;password=+1z)9.,!aEL%ZKI9@$MnaL><f;Trusted_Connection=False;MultipleActiveResultSets=true;Connection Timeout=1800;"
  }

Startup.cs

        services.AdddistributedsqlServerCache(options =>
        {
            options.ConnectionString = _config.GetConnectionString("ConnectionVar");
            options.SchemaName = "dbo";
            options.TableName = "sqlSessions";
            options.DefaultSlidingExpiration = TimeSpan.FromMinutes(30);
            options.ExpiredItemsDeletionInterval = TimeSpan.FromMinutes(30);
        });

我的问题:-

  • {"Execution Timeout Expired. 在操作完成之前超时时间已过或服务器没有响应。"} 在分布式 sql Server 缓存中

当调试遇到行 await distributedCache.SetStringAsync(KeyHere,options); 。记录超过 3000 行。

如果我遗漏了什么,请帮忙。或者需要在代码添加。在此先感谢您的支持和关注。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。