Is caching in C # the right approach for me?

I tried to read about caching in ASP.NET and still have a few questions.

  • When using Cql Cache dependencies ... I know that you can specify which tables will be monitored, but if any change happens to any of these tables, does this reset the entire cache? I understand that I donโ€™t want to cache tables that will have frequent changes, but we could get a good handful of cached tables and even if each table receives only a few updates per day, which can turn into a 50x cache flushing daily (8- hour window).

  • I would create and maintain this cache through the GAC DLL. A large number of different applications will have access to this PAC at any given time. Does each application support its own copy of the cache, or is it just stored in one global location (or, possibly, in the application pool)?

  • Is there a physical location on the server where I can see how much space the cache currently occupies? This would be extremely appropriate if each application kept its own cache, as this could lead to a large amount of disk space.

  • Is there a way to physically force the cache to rebuild itself? I could see that my boss believes that the cache was to blame for a particular problem, and I would have to resolve it at the very level. There is no "change of record and indication that SHOULD rebuild the cache", but rather "do [Action X] and KNOW that everything that was in the cache has now disappeared"

Thanks in advance for your answers and time.

+6
source share
2 answers
  • SqlCacheDependency controls only tables in the style of the old SQL 2000, which is based on triggers and polls. The SQL 2005+ method tracks row level changes and uses Service Broker. At the Cache object level, changes will only invalidate cache entries associated with this SqlCacheDependency (not the entire cache).

  • Each application has a separate copy of the cache. If you have many applications using the same data, you might consider creating a separate "caching server" and your applications will get their data there using WCF - basically add one more level to your application.

  • You can look at several performance counters related to the cache, but if your problem is with disk space, then you have nothing to worry about, because the ASP.NET cache is completely stored in RAM. Also, if the RAM becomes too full, one of the features of the cache is that it will let go of old / rarely used objects to make room for new objects.

  • The easiest way to get the cache to be dropped is to simply redesign the application or AppPool (which happens once a day or so by default by any means). If you need something more focused, you will need to write code to force removal of certain items from the cache using Cache.Remove () or using related dependencies.

+2
source

on top:

+1
source

Source: https://habr.com/ru/post/904707/


All Articles