I have 2 web applications in mvc5, webapp1, webapp2. By Autofac, I register this classes:
//cache managers
builder.RegisterType<MemoryCacheManager>().As<ICacheManager().Named<ICacheManager>("snt_cache_static").SingleInstance();
builder.RegisterType<SettingService>().As<ISettingService>().WithParameter(ResolvedParameter.ForNamed<ICacheManager>("snt_cache_static")).InstancePerLifetimeScope();
builder.RegisterType<TestController>()
.WithParameter(ResolvedParameter.ForNamed<ICacheManager>("snt_cache_static"));
When I modify and save into database a value with webapp2, I clear the cache and if I compare the new value with the stored in cache, ok, correspond, as once saved was deleted from chache.
However, if I compare the new value with the stored in cache through webapp1, it is still saved the old value.
the cache of WebApp1 should correspond to that of webapp2, because to read the cache in both sites I use the parameter "_settingService" or "_cacheManager" passed in controller by Autofac:
public TestController(
ISettingService settingService,
ICacheManager cacheManager
)
{
this._settingService = settingService;
this._cacheManager = cacheManager;
}
My question is: how do I share the cache in both applications?