MyProgramA function in requires a large amount of structured data, which is generated based on the combination of information in the database and configuration file. The data in the database is very stable and rarely changes; the configuration file is occasionally modified. In other words, the generation of this batch of data is very time-consuming, but it basically does not need to be changed once it is generated (unless I modify the configuration file, I will restart the site in that case ). Therefore, I use a static variable to represent this data. Its initialization process is encapsulated in a static constructor of the reader class, and some static methods are used to access this static variable.
My problem is:
1. Is it appropriate to use static variables to handle problems like me?
2. Using this method, does the data initialization process only need to be repeated as long as the site is not restarted? (I heard that when IIS occupies too much memory, some static variables will be recycled. I don't know which person can clearly explain that as long as the collection frequency is not too high, to meet my requirements .)