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