namespace IStation.Service
|
{
|
/// <summary>
|
/// AirpSite
|
/// 缓存辅助类
|
/// </summary>
|
internal class AirpSiteCacheHelper
|
{
|
private const string _contentKey = "AirpSiteList";
|
|
private static string GetCacheKey()
|
{
|
return CacheHelper.GetCacheKey(_contentKey);
|
}
|
|
/// <summary>
|
/// 设置缓存
|
/// </summary>
|
public static void Set(List<Model.AirpSite> list, int Minites = 30, int RandomSeconds = 0)
|
{
|
var cacheKey = GetCacheKey();
|
MemoryCacheHelper.Set(cacheKey, list, Minites * 60 + RandomSeconds);
|
}
|
|
/// <summary>
|
/// 获取缓存
|
/// </summary>
|
/// <returns></returns>
|
public static List<Model.AirpSite> Get()
|
{
|
var cacheKey = GetCacheKey();
|
return MemoryCacheHelper.Get<List<Model.AirpSite>>(cacheKey);
|
}
|
|
/// <summary>
|
/// 获取设置缓存
|
/// </summary>
|
public static List<Model.AirpSite> GetSet(Func<List<Model.AirpSite>> func, int Minites = 30, int RandomSeconds = 0)
|
{
|
var cacheKey = GetCacheKey();
|
return MemoryCacheHelper.GetSet(cacheKey, func, Minites * 60 + RandomSeconds);
|
}
|
|
/// <summary>
|
/// 移除缓存
|
/// </summary>
|
public static void Remove()
|
{
|
var cacheKey = GetCacheKey();
|
MemoryCacheHelper.Remove(cacheKey);
|
}
|
|
/// <summary>
|
/// 发布
|
/// </summary>
|
public static void Publish(string key)
|
{
|
var cacheKey = GetCacheKey();
|
MemoryCacheWipeRelationHelper.Set(key, cacheKey);
|
}
|
|
/// <summary>
|
/// 触发
|
/// </summary>
|
public static void Trigger()
|
{
|
var cacheKey = GetCacheKey();
|
MemoryCacheWipeRelationHelper.Trigger(cacheKey);
|
}
|
|
}
|
}
|