diff --git a/src/0-core/HuanMeng.MiaoYu.Code/Cache/CommonDataEntityCache.cs b/src/0-core/HuanMeng.MiaoYu.Code/Cache/CommonDataEntityCache.cs
index fd8775b..2a59e67 100644
--- a/src/0-core/HuanMeng.MiaoYu.Code/Cache/CommonDataEntityCache.cs
+++ b/src/0-core/HuanMeng.MiaoYu.Code/Cache/CommonDataEntityCache.cs
@@ -17,8 +17,19 @@ namespace HuanMeng.MiaoYu.Code.Cache
///
///
///
- public abstract class CommonDataEntityCache(object lockObj, int cacheTime = 36000) : ICacheClearData, ICacheReloadData where T : class
+ public abstract class CommonDataEntityCache : ICacheClearData, ICacheReloadData where T : class
{
+ //(object lockObj, int cacheTime = 36000)
+ protected object lockObj;
+ protected int cacheTime;
+
+ protected CommonDataEntityCache(object lockObj, int cacheTime = 36000)
+ {
+ this.lockObj = lockObj;
+ this.cacheTime = cacheTime;
+ }
+
+
///
///
///
diff --git a/src/0-core/HuanMeng.MiaoYu.Code/Cache/MiaoYuCache.cs b/src/0-core/HuanMeng.MiaoYu.Code/Cache/MiaoYuCache.cs
index 884fcbc..ca08d7c 100644
--- a/src/0-core/HuanMeng.MiaoYu.Code/Cache/MiaoYuCache.cs
+++ b/src/0-core/HuanMeng.MiaoYu.Code/Cache/MiaoYuCache.cs
@@ -2,9 +2,13 @@
using AutoMapper;
+using HuanMeng.MiaoYu.Code.Cache.Contract;
using HuanMeng.MiaoYu.Code.Cache.Special;
+using HuanMeng.MiaoYu.Code.DataAccess;
using HuanMeng.MiaoYu.Model.Dto.Character;
+using System.Linq.Expressions;
+
namespace HuanMeng.MiaoYu.Code.Cache
{
///
@@ -217,7 +221,7 @@ namespace HuanMeng.MiaoYu.Code.Cache
object cacheLock;
if (!CacheLockList.TryGetValue(typeof(T), out cacheLock))
{
- Console.WriteLine("没有找到锁对象==>"+typeof(T).Name);
+ Console.WriteLine("没有找到锁对象==>" + typeof(T).Name);
// 创建一个新的锁对象,并添加到 CacheLockList 中
cacheLock = new object();
CacheLockList[typeof(T)] = cacheLock;
@@ -235,6 +239,27 @@ namespace HuanMeng.MiaoYu.Code.Cache
var cache = GetMiaoYuDataEntityCache(dao);
return cache?.DataList ?? new List();
}
+
+ ///
+ /// 清除全部缓存
+ ///
+ ///
+ public static void ClareMiaoYuDataEntityCache(DAO dao)
+ {
+ foreach (var item in CacheLockList)
+ {
+ var t = item.Key;
+ Type cacheType = typeof(MiaoYuDataEntityCache<>).MakeGenericType(t);
+ var shujuduixiang = Activator.CreateInstance(cacheType, dao, item.Value,36000);
+ var x = shujuduixiang as ICacheClearData;
+ if (x != null)
+ {
+ x.ClearData();
+ }
+ //new MiaoYuDataEntityCache(dao, cacheLock);
+ //Activator.CreateInstance(t);
+ }
+ }
#endregion
#region 图片扩展
diff --git a/src/0-core/HuanMeng.MiaoYu.Code/Other/OtherBLL.cs b/src/0-core/HuanMeng.MiaoYu.Code/Other/OtherBLL.cs
new file mode 100644
index 0000000..cbb8b7c
--- /dev/null
+++ b/src/0-core/HuanMeng.MiaoYu.Code/Other/OtherBLL.cs
@@ -0,0 +1,27 @@
+using HuanMeng.MiaoYu.Code.Cache;
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HuanMeng.MiaoYu.Code.Other
+{
+ ///
+ /// 杂项
+ ///
+ ///
+ public class OtherBLL(IServiceProvider serviceProvider) : MiaoYuBase(serviceProvider)
+ {
+ ///
+ /// 清除缓存
+ ///
+ ///
+ public Task CleraCache()
+ {
+ MiaoYuCacheExtend.ClareMiaoYuDataEntityCache(Dao);
+ return Task.CompletedTask;
+ }
+ }
+}
diff --git a/src/2-api/HuanMeng.MiaoYu.WebApi/Controllers/OtherController.cs b/src/2-api/HuanMeng.MiaoYu.WebApi/Controllers/OtherController.cs
new file mode 100644
index 0000000..6c3d6f5
--- /dev/null
+++ b/src/2-api/HuanMeng.MiaoYu.WebApi/Controllers/OtherController.cs
@@ -0,0 +1,30 @@
+using HuanMeng.MiaoYu.Code.Other;
+using HuanMeng.MiaoYu.WebApi.Base;
+
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+
+namespace HuanMeng.MiaoYu.WebApi.Controllers
+{
+ [Route("api/[controller]")]
+ [ApiController]
+ public class OtherController : MiaoYuControllerBase
+ {
+ public OtherController(IServiceProvider _serviceProvider) : base(_serviceProvider)
+ {
+ }
+ ///
+ /// 清除缓存
+ ///
+ ///
+ [HttpGet("cache/clear")]
+ [AllowAnonymous]
+ public async Task Clear()
+ {
+ OtherBLL otherBLL = new OtherBLL(ServiceProvider);
+ await otherBLL.CleraCache();
+
+ }
+ }
+}