/// <summary> /// 加载配置。 /// </summary> /// <typeparam name="TModel">配置类型。</typeparam> /// <param name="name">名称,不包含文件扩展名。</param> /// <param name="minutes">缓存分钟数。</param> /// <returns>返回配置实例。</returns> public virtual async Task <TModel> LoadDataAsync <TModel>(string name, int minutes = -1) { if (minutes <= 0) { return(Cores.FromJsonString <TModel>(await LoadFileAsync(name))); } return(await _cache.GetOrCreateAsync(GetCacheKey(name), async ctx => { ctx.SetAbsoluteExpiration(TimeSpan.FromMinutes(minutes)); return Cores.FromJsonString <TModel>(await LoadFileAsync(name)); })); }
/// <summary> /// 加载配置。 /// </summary> /// <typeparam name="TModel">配置类型。</typeparam> /// <param name="name">名称,不包含文件扩展名。</param> /// <param name="minutes">缓存分钟数。</param> /// <returns>返回配置实例。</returns> public virtual TModel LoadData <TModel>(string name, int minutes = -1) { if (minutes <= 0) { return(Cores.FromJsonString <TModel>(LoadFile(name))); } return(_cache.GetOrCreate(GetCacheKey(name), ctx => { ctx.SetAbsoluteExpiration(TimeSpan.FromMinutes(minutes)); return Cores.FromJsonString <TModel>(LoadFile(name)); })); }