using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace IStation.Service
|
{
|
/// <summary>
|
/// Estate»º´æ¸¨ÖúÀà
|
/// </summary>
|
internal class EstateCacheHelper
|
{
|
private const string _contentKey = "EstateListKey";
|
|
private static string GetCacheKey(long CorpID)
|
{
|
var contentKey = string.Format("{0}-{1}", _contentKey, CorpID);
|
return CacheHelper.GetCacheKey(contentKey);
|
}
|
|
/// <summary>
|
/// ÉèÖûº´æ
|
/// </summary>
|
public static void Set(long CorpID, List<Model.Estate> list, int Minites = 30, int RandomSeconds = 0)
|
{
|
var cacheKey = GetCacheKey(CorpID);
|
MemoryCacheHelper.Set(cacheKey, list, Minites * 60 + RandomSeconds);
|
}
|
|
/// <summary>
|
/// »ñÈ¡»º´æ
|
/// </summary>
|
public static List<Model.Estate> Get(long CorpID)
|
{
|
var cacheKey = GetCacheKey(CorpID);
|
return MemoryCacheHelper.Get<List<Model.Estate>>(cacheKey);
|
}
|
|
/// <summary>
|
/// »ñÈ¡ÉèÖûº´æ
|
/// </summary>
|
public static List<Model.Estate> GetSet(long CorpID, Func<List<Model.Estate>> func, int Minites = 30, int RandomSeconds = 0)
|
{
|
var cacheKey = GetCacheKey(CorpID);
|
return MemoryCacheHelper.GetSet(cacheKey, func, Minites * 60 + RandomSeconds);
|
}
|
|
/// <summary>
|
/// ÒÆ³ý»º´æ
|
/// </summary>
|
public static void Remove(long CorpID)
|
{
|
var cacheKey = GetCacheKey(CorpID);
|
MemoryCacheHelper.Remove(cacheKey);
|
}
|
|
/// <summary>
|
/// È«²¿ÒƳý
|
/// </summary>
|
public static void RemoveAll()
|
{
|
MemoryCacheHelper.Remove((key) =>
|
{
|
return key.Contains(CacheHelper.GetCacheKey(_contentKey));
|
});
|
}
|
|
|
}
|
}
|