저는 NopCommerce 2.40에서 작업하고 있습니다. CacheManager를 사용하여 홈 페이지에서 Cache를 설정하려고합니다.Nopcommerce PerRequestCacheManager 대 MemoryCacheManager
var cacheModel = _cacheManager.Get(cacheKey,() =>
{
var model = new HomePageProductsModel()
{
....
....
}
return model;
});
이 코드를 디버깅 할 때. 그것은 MemoryCacheManager에서 Get 메소드를 친다. 이제 관리자 쪽에서 어떤 제품을 업데이트 할 때 Key로이 캐시를 제거하려고합니다. 아래에있는 PerRequestCacheManager의 Remove 메소드를 제거하십시오.
_cacheManager.Remove(string.Format("product.hometemplate-{0}-{1}", storeid, true));
홈페이지의 캐시는 삭제되지 않습니다. 어떤 해결책이 있습니까?
감사합니다. @ and.maz. 이 문은 builder.RegisterType()를 사용하여 ImportManager 서비스에 대한 DependencyRegistrar를 변경했습니다. () .WithParameter (ResolvedParameter.ForNamed ("nop_cache_static")) InstancePerHttpRequest(); ImportManager에서 캐시를 지우는 방법을 쓰고 있기 때문에 괜찮을까요? –
현재 MemoryCache는 60 분으로 설정되어 있습니다. 수동으로 제거하기 전까지는 영원히 가질 수 있습니다. 매일 그것을 제거하려고합니다. –