Sharing HttpRuntime.Cache Through Two IIS Applications

I have two ASP.NET 2.0 applications in IIS; a public reservation system and an administrative system for managing prices. There is a common DLL project that accesses the database used by both applications.

To improve performance, prices are cached in a DLL code to keep a hit on the database for each request. However, when an administrator changes prices, the cache is updated in the administrator’s application (and, obviously, it is not updated in the public application)

So to the question. Is it possible to configure IIS so that these two applications share HttpRuntime.Cache? If so, how to configure it?

+4
source share
2 answers

This will mean that you have two applications - they should not use the same heap of DLL memory, which would be necessary. You need a communication channel between them, and the admin web pages report changes in the cache, which would cause an update.

Maybe something simple, but maybe the simple page you publish makes the cache check for updates? Or - periodically check for updates based on timestamps.

(Another option is to create a service that stores the cache, but I think this goes beyond a simple solution)

+2
source

No; from experience this will not work (.NET 4.6, IIS 8.5, 2 applications - a regular DLL using the same application pool). The documentation is very complicated (outside the "cache elements are stored in memory" ) - in fact, the only descriptive part was that @Thies was mentioned above - but, as he stated, I believe that this is because the cache is stored in the allocated DLL memory, therefore (since we still have one process, but two application domains ), the shared DLL is loaded separately into the two application domains, and the DLL memory is not used.

0
source

All Articles