From 2a39f1db4c6f2ad5853041c6b7e5aa2e25492cb6 Mon Sep 17 00:00:00 2001 From: Argo-MacBookPro Date: Sun, 28 Oct 2018 15:42:06 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E4=BB=A3=E7=A0=81=EF=BC=9A?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8Dict=E7=B1=BB=E4=B8=AD=E7=9A=84=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E5=88=B0DictHelper=E7=B1=BB=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.DataAccess/CacheCleanUtility.cs | 4 ++-- Bootstrap.DataAccess/Dict.cs | 7 ------- Bootstrap.DataAccess/Helper/DictHelper.cs | 12 +++++++++++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Bootstrap.DataAccess/CacheCleanUtility.cs b/Bootstrap.DataAccess/CacheCleanUtility.cs index a40e20da..7a4b50b7 100644 --- a/Bootstrap.DataAccess/CacheCleanUtility.cs +++ b/Bootstrap.DataAccess/CacheCleanUtility.cs @@ -73,9 +73,9 @@ namespace Bootstrap.DataAccess } if (dictIds != null) { - cacheKeys.Add(Dict.RetrieveDictsDataKey + "*"); + cacheKeys.Add(DictHelper.RetrieveDictsDataKey + "*"); cacheKeys.Add(DictHelper.RetrieveCategoryDataKey); - corsKeys.Add(Dict.RetrieveDictsDataKey + "*"); + corsKeys.Add(DictHelper.RetrieveDictsDataKey + "*"); } if (cacheKey != null) { diff --git a/Bootstrap.DataAccess/Dict.cs b/Bootstrap.DataAccess/Dict.cs index f6ec7bb1..3fcdf758 100644 --- a/Bootstrap.DataAccess/Dict.cs +++ b/Bootstrap.DataAccess/Dict.cs @@ -13,13 +13,6 @@ namespace Bootstrap.DataAccess /// public class Dict : BootstrapDict { - /// - /// - /// - /// - /// 缓存索引,BootstrapAdmin后台清理缓存时使用 - /// - public const string RetrieveDictsDataKey = "BootstrapDict-RetrieveDicts"; /// /// 删除字典中的数据 /// diff --git a/Bootstrap.DataAccess/Helper/DictHelper.cs b/Bootstrap.DataAccess/Helper/DictHelper.cs index b3a98c5c..c9ac38ca 100644 --- a/Bootstrap.DataAccess/Helper/DictHelper.cs +++ b/Bootstrap.DataAccess/Helper/DictHelper.cs @@ -10,12 +10,22 @@ namespace Bootstrap.DataAccess /// public static class DictHelper { + /// + /// + /// + /// + /// 缓存索引,BootstrapAdmin后台清理缓存时使用 + /// + public const string RetrieveDictsDataKey = "BootstrapDict-RetrieveDicts"; + /// + /// + /// public const string RetrieveCategoryDataKey = "DictHelper-RetrieveDictsCategory"; /// /// /// /// - public static IEnumerable RetrieveDicts() => DbAdapterManager.Create().RetrieveDicts(); + public static IEnumerable RetrieveDicts() => CacheManager.GetOrAdd(RetrieveDictsDataKey, key => DbAdapterManager.Create().RetrieveDicts()); /// /// 删除字典中的数据 ///