キャッシングサービスを作成していて、データをキャッシュするのにMemorycacheを使用しています。キャッシュされたデータは12時間後に有効期限が切れるように設定されています。 1時間後、キャッシュされたデータは消滅します。 IIS(7.0)ワーカープールは、1740分後に有効期限が切れるように構成されています。私は約200 Mのデータをキャッシュしており、各キャッシュ項目は100バイト未満です。MemoryCache:キャッシュされたアイテムの有効期限が正しく設定されていません
誰もがこの問題に直面しているか、私はここで何か間違っている可能性がありますか?
私がMemoryCache
をインスタンス化するために使用したコードは次のとおりです。
private const string ConstCacheMemoryLimitMegabytes = "cacheMemoryLimitMegabytes";
private const string ConstCacheMemoryLimitMegabytesValue = "2000";
private const int CacheDefaultTimeOut = 720;
// Percentage of server memory to use
private const string ConstPhysicalMemoryLimitPercentage = "physicalMemoryLimitPercentage";
private const string ConstPhysicalMemoryLimitPercentageValue = "100";
// The maximum time that can occur before memory statistics are updated.
private const string ConstPollingInterval = "pollingInterval";
private const string ConstPollingIntervalValue = "02:00:00";
var config = new NameValueCollection
{
{ ConstCacheMemoryLimitMegabytes, ConstCacheMemoryLimitMegabytesValue },
{ ConstPhysicalMemoryLimitPercentage, ConstPhysicalMemoryLimitPercentageValue },
{ ConstPollingInterval, ConstPollingIntervalValue}
};
var _cachePolicy = new CacheItemPolicy
{
AbsoluteExpiration = ConvertIntToMinDateTimeOffSet(CacheDefaultTimeOut) // Setting this to expire 12 hours later.
};
_memoryCache = new MemoryCache("MyCustomCache", config);
var cacheItem = new CacheItem(key, item);
_memoryCache.Add(cacheItem, _cachePolicy);
private static DateTimeOffset ConvertIntToMinDateTimeOffSet(int cacheExpiryIntervalInMinute)
{
return new DateTimeOffset(DateTime.Now.AddMinutes(cacheExpiryIntervalInMinute));
}
タイムゾーンはUTC + 8時00分(KL、シンガポール)
あなたが住んでいる時間帯を文書化してください。 –