兼容win7版应用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.6 KiB

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
namespace AIK.Service.IService
{
public interface IFileCacheService
{
/// <summary>
/// 异步获取文件。优先从缓存中获取,若不存在或已过期则从网络下载。
/// </summary>
/// <param name="fileUrl">第三方文件地址</param>
/// <param name="cacheKey">自定义缓存键(可选)</param>
/// <returns>缓存的文件数据</returns>
Task<byte[]> GetFileByteAsync(string fileUrl, string cacheKey = null, CancellationToken cancellationToken = default);
/// <summary>
/// 带进度的文件下载方法。优先从缓存中获取,若不存在或已过期则从网络下载。
/// </summary>
/// <param name="fileUrl"></param>
/// <param name="cacheKey"></param>
/// <param name="progress"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<(bool success, string localFilePath)> DownloadFileWithProgressAsync(string fileUrl, string cacheKey, IProgress<double> progress = null, CancellationToken cancellationToken = default);
/// <summary>
/// 清除所有过期的缓存文件。(bin文件默认无过期期限)
/// </summary>
Task ClearExpiredCacheAsync();
/// <summary>
/// 强制清除所有缓存(内存和磁盘)。
/// </summary>
Task ClearAllCacheAsync();
}
}