Analysis of the difference between Session cache and Cache cache in asp.net
- 2020-05-27 04:44:16
- OfStack
Among them, Cookie is a group of data saved in the client, which is mainly used to save personal information such as user name.
Session saves the conversation.
Application, on the other hand, is information stored across the entire application, which ACTS as a global variable.
Session is used a lot.
The differences between the Session cache and the Cache cache can be summarized as follows:
1. The biggest difference is that Cache provides a cache dependency to update data, while Session can only judge whether the cache data is valid or not based on the defined cache time.
2. Even if the application terminates, as long as the cache time defined in the Cache.Add method is not expired, the cached data will still exist the next time the application is opened. The Session cache only exists in one session, after which the data is invalidated.
3. Session is easy to lose, resulting in the uncertainty of data, which is not the case with Cache.
4. Since Session is loaded every session, it is not appropriate to store a large amount of information, otherwise it will lead to the performance degradation of the server. Cache, on the other hand, is primarily used to hold large volumes of information, such as multiple tables in a database.
5. The beta version of VS2005 provided the parameter to save the cache on the hard disk, but this feature was removed from the official version and is expected to be re-implemented in a later version. At present, Session can only be saved in memory, which has an impact on its performance.
Session saves the conversation.
Application, on the other hand, is information stored across the entire application, which ACTS as a global variable.
Session is used a lot.
The differences between the Session cache and the Cache cache can be summarized as follows:
1. The biggest difference is that Cache provides a cache dependency to update data, while Session can only judge whether the cache data is valid or not based on the defined cache time.
2. Even if the application terminates, as long as the cache time defined in the Cache.Add method is not expired, the cached data will still exist the next time the application is opened. The Session cache only exists in one session, after which the data is invalidated.
3. Session is easy to lose, resulting in the uncertainty of data, which is not the case with Cache.
4. Since Session is loaded every session, it is not appropriate to store a large amount of information, otherwise it will lead to the performance degradation of the server. Cache, on the other hand, is primarily used to hold large volumes of information, such as multiple tables in a database.
5. The beta version of VS2005 provided the parameter to save the cache on the hard disk, but this feature was removed from the official version and is expected to be re-implemented in a later version. At present, Session can only be saved in memory, which has an impact on its performance.