I. Summary
Ii. Technical Background
Design Points: find common points and change points of functions.
Commonalities:
Cache allows you to quickly obtain data stored in the memory. When data is accessed again, the application obtains data from the cache instead of the original data source. This can improve performance and scalability. In addition, when the data source is temporarily unavailable, the cache makes the data available.
Change Point.
The most important change in cache design is the update policy (Expiration Policy ).
Common update policies include real-time detection, heartbeat detection, cache dependency detection, absolute expiration, and sliding expiration. Of course, in the ApplicationProgramDesigning,
A general cache framework, the specific cache location is also a common change point, such as memory, files, databases, networks, and clouds.
In the specific design, pay attention to these two changes.
Knowledge points to use:
Decoration Mode
The architecture of the. net4.0 Scalable Cache System. runtime. caching
System. runtime. caching class diagram:
The core of the Code is objectcache (Cache container)
The memorycache class is a memory cache that implements the objectcache class. You can use it to complete most of the work.
The prototype of the memorycache class is defined in the ASP. NET cache object in the system. Web. caching space. Therefore, the internal cache logic is similar to the cache logic provided by the early ASP. NET.
Abstract base classes provide the following functions:
- Create and manage caches.
- Specify expiration and revocation.
- This event is triggered when the cache information changes.
Changemonitor provides a base class for derived custom types used to monitor the status changes of the data that the cache items depend on
Sqlchangemonitor monitors changes to the SQL Server database
Hostfilechangemonitor monitors directories and file paths, and notifies the cache of changes to monitored items
Filechangemonitor indicates the object used to monitor changes to the file.
Create your own cache provider:
- Create a class that inherits objectcache and provides custom cache implementation.
- Create a class that integrates memorycache and provides custom cache implementation.
- Create a class that inherits outputcacheprovider and configure the application to use this custom output cache provider.
-
Iii. OEA Cache