重构代码:移动Dict类中的缓存到DictHelper类中

This commit is contained in:
Argo-MacBookPro 2018-10-28 15:42:06 +08:00
parent 81fce99357
commit 2a39f1db4c
3 changed files with 13 additions and 10 deletions

View File

@ -73,9 +73,9 @@ namespace Bootstrap.DataAccess
} }
if (dictIds != null) if (dictIds != null)
{ {
cacheKeys.Add(Dict.RetrieveDictsDataKey + "*"); cacheKeys.Add(DictHelper.RetrieveDictsDataKey + "*");
cacheKeys.Add(DictHelper.RetrieveCategoryDataKey); cacheKeys.Add(DictHelper.RetrieveCategoryDataKey);
corsKeys.Add(Dict.RetrieveDictsDataKey + "*"); corsKeys.Add(DictHelper.RetrieveDictsDataKey + "*");
} }
if (cacheKey != null) if (cacheKey != null)
{ {

View File

@ -13,13 +13,6 @@ namespace Bootstrap.DataAccess
/// </summary> /// </summary>
public class Dict : BootstrapDict public class Dict : BootstrapDict
{ {
/// <summary>
///
/// </summary>
/// <summary>
/// 缓存索引BootstrapAdmin后台清理缓存时使用
/// </summary>
public const string RetrieveDictsDataKey = "BootstrapDict-RetrieveDicts";
/// <summary> /// <summary>
/// 删除字典中的数据 /// 删除字典中的数据
/// </summary> /// </summary>

View File

@ -10,12 +10,22 @@ namespace Bootstrap.DataAccess
/// </summary> /// </summary>
public static class DictHelper public static class DictHelper
{ {
/// <summary>
///
/// </summary>
/// <summary>
/// 缓存索引BootstrapAdmin后台清理缓存时使用
/// </summary>
public const string RetrieveDictsDataKey = "BootstrapDict-RetrieveDicts";
/// <summary>
///
/// </summary>
public const string RetrieveCategoryDataKey = "DictHelper-RetrieveDictsCategory"; public const string RetrieveCategoryDataKey = "DictHelper-RetrieveDictsCategory";
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public static IEnumerable<BootstrapDict> RetrieveDicts() => DbAdapterManager.Create<Dict>().RetrieveDicts(); public static IEnumerable<BootstrapDict> RetrieveDicts() => CacheManager.GetOrAdd(RetrieveDictsDataKey, key => DbAdapterManager.Create<Dict>().RetrieveDicts());
/// <summary> /// <summary>
/// 删除字典中的数据 /// 删除字典中的数据
/// </summary> /// </summary>