chore
This commit is contained in:
@@ -93,7 +93,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 国家数据缓存树形结构
|
/// 国家数据缓存树形结构
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string CountryTree = "Area.CountryTree";
|
public const string CountryTree = "Area.CountryTree.";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 国家数据缓存
|
/// 国家数据缓存
|
||||||
|
|||||||
@@ -39,12 +39,14 @@ namespace Atomx.Data.CacheServices
|
|||||||
/// <param name="countryId"></param>
|
/// <param name="countryId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
List<KeyValueTree> GetAreaTreeAsync(long countryId);
|
List<KeyValueTree> GetAreaTreeAsync(long countryId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public partial class CacheService : ICacheService
|
public partial class CacheService : ICacheService
|
||||||
{
|
{
|
||||||
public async Task<List<KeyValueTree>> GetAreaTreeAsync(long countryId, bool? reload = false)
|
public async Task<List<KeyValueTree>> GetAreaTreeAsync(long countryId, bool? reload = false)
|
||||||
{
|
{
|
||||||
var cacheData = await GetCacheAsync<List<KeyValueTree>>(CacheKeys.CountryTree);
|
var cacheData = await GetCacheAsync<List<KeyValueTree>>($"{CacheKeys.CountryTree}{countryId}");
|
||||||
if (cacheData == null || reload.HasValue && reload.Value)
|
if (cacheData == null || reload.HasValue && reload.Value)
|
||||||
{
|
{
|
||||||
var state = _dbContext.StateProvinces.Where(p => p.CountryId == countryId).ToList();
|
var state = _dbContext.StateProvinces.Where(p => p.CountryId == countryId).ToList();
|
||||||
@@ -64,7 +66,7 @@ namespace Atomx.Data.CacheServices
|
|||||||
}).ToList();
|
}).ToList();
|
||||||
await SetCacheAsync(CacheKeys.Country, cacheData);
|
await SetCacheAsync(CacheKeys.Country, cacheData);
|
||||||
}
|
}
|
||||||
return cacheData;
|
return cacheData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<Area>> GetCountry(bool? reload = false)
|
public async Task<List<Area>> GetCountry(bool? reload = false)
|
||||||
|
|||||||
Reference in New Issue
Block a user