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.
46 lines
1.9 KiB
46 lines
1.9 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Media.Imaging;
|
|
|
|
namespace AIK.Service.IService
|
|
{
|
|
public interface IImageCacheService
|
|
{
|
|
/// <summary>
|
|
/// 异步获取图片。优先从缓存中获取,若不存在或已过期则从网络下载。
|
|
/// </summary>
|
|
/// <param name="imageUrl">第三方图片地址</param>
|
|
/// <param name="cacheKey">自定义缓存键(可选)</param>
|
|
/// <returns>缓存的图片</returns>
|
|
Task<BitmapImage> GetImageAsync(string imageUrl, string cacheKey = null, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// 异步获取图片。优先从缓存中获取,若不存在或已过期则从网络下载。
|
|
/// </summary>
|
|
/// <param name="imageUrl">第三方图片地址</param>
|
|
/// <param name="cacheKey">自定义缓存键(可选)</param>
|
|
/// <returns>缓存的图片</returns>
|
|
Task<BitmapImage> GetImageByLocalPathAsync(string imageUrl, string cacheKey = null, CancellationToken cancellationToken = default);
|
|
/// <summary>
|
|
/// 返回本地存储的文件路径
|
|
/// </summary>
|
|
/// <param name="imageUrl"></param>
|
|
/// <param name="cacheKey"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns>缓存的图片文件本地路径</returns>
|
|
Task<string> GetImagePathAsync(string imageUrl, string cacheKey = null, CancellationToken cancellationToken = default);
|
|
/// <summary>
|
|
/// 清除所有过期的缓存文件。
|
|
/// </summary>
|
|
Task ClearExpiredCacheAsync();
|
|
|
|
/// <summary>
|
|
/// 强制清除所有缓存(内存和磁盘)。
|
|
/// </summary>
|
|
Task ClearAllCacheAsync();
|
|
}
|
|
}
|
|
|