EnterpriseLibrary cacheManager を使用しています
<cacheManagers>
<add name="NonExperimentalAppsCache" type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null" expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="10000" numberToRemoveWhenScavenging="100" backingStoreName="Null Storage" />
</cacheManagers>
実験時間を 1 分にしたい (キャッシュに触れるたびに更新しない絶対値) どうすればよいですか? データをより長く保存できるようになったためです。
キャッシュ経由でリポジトリを使用します
public static List<string> GetAllNonExperimentalAppsNames()
{
List<string> nonExperimentalAppsNames = NonExperimentalAppsCacheManager.Get();
if (nonExperimentalAppsNames == null)
{
//was not found in the cache
nonExperimentalAppsNames = GetAllNonExperimentalAppsNamesFromDb();
if (nonExperimentalAppsNames != null)
{
NonExperimentalAppsCacheManager.Set(nonExperimentalAppsNames);
}
else
{
mApplicationLogger.Info(string.Format("GetAllNonExperimentalAppsNames:: nonExperimentalAppsNames list is null"));
}
}
return nonExperimentalAppsNames;
}
..
internal static class NonExperimentalAppsCacheManager
{
private const string NONEXPERIMENTALAPPS = "NonExperimentalApps";
private static readonly ICacheManager nonExperimentalAppsCache = CacheFactory.GetCacheManager("NonExperimentalAppsCache");
internal static List<String> Get()
{
return nonExperimentalAppsCache[NONEXPERIMENTALAPPS] as List<String>;
}
internal static void Set(List<String> settings)
{
nonExperimentalAppsCache.Add(NONEXPERIMENTALAPPS, settings);
}
}