【新增】redis缓存仓储增加通过Lua脚本查询key的方法,商品增加删除后清理首页缓存的功能。

This commit is contained in:
大灰灰
2022-12-07 01:22:26 +08:00
parent ed879baf4a
commit 3d3546ae80
3 changed files with 208 additions and 61 deletions

View File

@@ -15,6 +15,7 @@ using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using CoreCms.Net.Caching.AutoMate.RedisCache;
using CoreCms.Net.Configuration;
using CoreCms.Net.Filter;
using CoreCms.Net.IServices;
@@ -58,6 +59,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
private readonly ICoreCmsUserGradeServices _userGradeServices;
private readonly ICoreCmsProductsDistributionServices _productsDistributionServices;
private readonly IWebHostEnvironment _webHostEnvironment;
private readonly IRedisOperationRepository _redisOperationRepository;
/// <summary>
@@ -76,7 +78,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
, ICoreCmsGoodsCategoryExtendServices categoryExtendServices
, ICoreCmsLabelServices labelServices
, ICoreCmsProductsDistributionServices productsDistributionServices
, ICoreCmsGoodsTypeSpecServices goodsTypeSpecServices)
, ICoreCmsGoodsTypeSpecServices goodsTypeSpecServices, IRedisOperationRepository redisOperationRepository)
{
_webHostEnvironment = webHostEnvironment;
_coreCmsGoodsServices = coreCmsGoodsServices;
@@ -92,6 +94,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
_labelServices = labelServices;
_productsDistributionServices = productsDistributionServices;
_goodsTypeSpecServices = goodsTypeSpecServices;
_redisOperationRepository = redisOperationRepository;
}
#region ============================================================
@@ -531,6 +534,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
{
await _productsServices.UpdateAsync(p => new CoreCmsProducts() { isDel = true },
p => p.goodsId == model.id);
await _redisOperationRepository.LikeRemoveAsync("SqlSugarDataCache.GoodListDTO." + "*");
}
jm.code = bl ? 0 : 1;
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;