diff --git a/Src/Asp.Net/SqlSugar/Infrastructure/ContextMethods.cs b/Src/Asp.Net/SqlSugar/Infrastructure/ContextMethods.cs index e6ac8494b..1cd85fdb7 100644 --- a/Src/Asp.Net/SqlSugar/Infrastructure/ContextMethods.cs +++ b/Src/Asp.Net/SqlSugar/Infrastructure/ContextMethods.cs @@ -1048,6 +1048,16 @@ namespace SqlSugar { ReflectionInoCore.GetInstance().Remove(key); } + public void RemoveCacheByLikeKey(string key) + { + foreach (var item in ReflectionInoCore.GetInstance().GetAllKey()) + { + if (item!=null&&key!=null&&item.Contains(key)) + { + ReflectionInoCore.GetInstance().Remove(item); + } + } + } #endregion #region Page Each diff --git a/Src/Asp.Net/SqlSugar/Interface/IContextMethods.cs b/Src/Asp.Net/SqlSugar/Interface/IContextMethods.cs index 7586b7ba6..431777fea 100644 --- a/Src/Asp.Net/SqlSugar/Interface/IContextMethods.cs +++ b/Src/Asp.Net/SqlSugar/Interface/IContextMethods.cs @@ -42,6 +42,7 @@ namespace SqlSugar ICacheService GetReflectionInoCacheInstance(); void RemoveCacheAll(); void RemoveCacheAll(); + void RemoveCacheByLikeKey(string key); void RemoveCache(string key); void PageEach(IEnumerable pageItems, int pageSize, Action> action); Task PageEachAsync(IEnumerable pageItems, int pageSize, Func, Task> action);