This commit is contained in:
yxw
2025-12-31 18:16:37 +08:00
parent 41371cfbee
commit 85c91244cd
2 changed files with 5 additions and 3 deletions

View File

@@ -93,7 +93,7 @@
/// <summary>
/// 国家数据缓存树形结构
/// </summary>
public const string CountryTree = "Area.CountryTree";
public const string CountryTree = "Area.CountryTree.";
/// <summary>
/// 国家数据缓存

View File

@@ -39,12 +39,14 @@ namespace Atomx.Data.CacheServices
/// <param name="countryId"></param>
/// <returns></returns>
List<KeyValueTree> GetAreaTreeAsync(long countryId);
}
public partial class CacheService : ICacheService
{
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)
{
var state = _dbContext.StateProvinces.Where(p => p.CountryId == countryId).ToList();