absrtact: This paper introduces the basic concept of caching and the commonly used caching technology, gives a brief introduction of the implementation mechanism of various technologies and the scope of application, as well as the problems to be considered in designing the caching scheme (total 17 pages) 1 concept 1.1 caching can solve the problem
· Performance-storage of the data to avoid duplication, processing, and transmission of data can improve performance effectively. such as the cache of unchanged data, such as the country list, which can significantly improve the response speed of the Web program;
· Stability--the same application often occurs when multiple requests are made to the same data, logical functions, and user interfaces. When the user base is very large, if each request is processed, the consumption of resources is a great waste, but also caused the system instability. For example, in Web applications, caching the rendering content of some static pages can effectively save resources and improve stability. The cached data can also reduce the number of accesses to the database, reduce the burden of the database and improve the service ability of the database.
· Availability--Sometimes, services that provide data information may stop unexpectedly, and if caching technology is used, it is possible to provide support to end users for a certain period of time, increasing the availability of the system. 1.2 Understanding States
Before you delve into the caching technology, you need to have an understanding of the state, because caching can be said to be a framework for state management. Understanding the meaning of State and some of its features-such as lifetime and survival-is a great help in determining whether to cache and choose the right caching technology. State refers to some data in the application system at a point in time, the state and condition of the data. This data may be permanently stored in the database, may be only in memory for a while, or may be based on a logic to survive (such as how long after the release), it may be the scope of application of all users can access, may be a single user has permissions; 1.2.1 Status Lifetime
A lifetime is a time interval in which data remains valid, from creation to removal. The usual lifetimes are as follows:
• Permanent state Permanent state--application use of permanent data;
• Process state processes state--are only valid during the process cycle;
• Session-state sessions state--related to specific user sessions;
• Message Status Messages state--the duration of the processing of a message; the range of 1.2.2 States
The scope of a state refers to the physical or logical scope that has access to that state.
• Physical scope refers to the physical location of the state data that can be accessed, usually including:
1. Organization organization--all applications within an organization can access state data;
2. Field farm--can be accessed on any machine within the scope of the application field;
3, machine machine--within the scope of a single machine can be accessed;
4, the process process--the process of access permits;
5. application domain appdomain--access permissions within the application domain.
• Logical range refers to the logical scope of accessible state data, which is common:
1, application application;
2, business processes business process;
3, Roles role;
4, users user; 1.2.3 status Data stale
Cached state data is only a snapshot of the master data (master State), and because the data source may be modified, the status data has an aging feature. It is an important task for caching state data to minimize the negative impact of using this attribute and data obsolescence. You can define the stale basis of the data in a way:
• The likelihood of master data changes-as time progresses, whether the master data changes are likely to increase significantly. Follow this to determine the obsolescence of cached state data;
• Change Dependencies--when the primary data is updated, the cached state data is not updated accordingly and does not affect the use of the system. For example, changing the appearance of a system does not have a significant impact on the business. 1.2.4 State data stale tolerance
The stale effect of cached state data on business processes is called tolerance, which can be tolerated (no tolerance) and a certain degree of tolerance (some tolerance), the former must be synchronized with the master data, which allows for a certain amount of time or a certain range of obsolescence, The standard of judgment is the degree of influence on the business process. 1.2.5 to understand the transformation process of state data
Another attribute of the state is the representation at different stages. The data stored in the database is in the original format, the data in the business process is processed, and the end user is presented in a different form. As shown in the following table:
Forms of Expression |
Describe |
Example |
Raw data |
The original form of the data |
such as data in a database |
Processed data |
Data processed in the business process for raw data |
Data forms in the business process |
Render Form |
Forms that can be presented to end users |
HTML or an understandable text description |
When you decide to cache data, you should consider which phase (in which form) the state data is cached. The following guidelines will help you make decisions:
· When the business logic can tolerate the stale cached data, the original data is cached, and the raw data can be persisted in the database access component and the service proxy;
• Cache processed data to reduce processing time and resources; processed data can be slowed down by business logic components and service interfaces.
• Cache rendering data (such as a TreeView control that contains large amounts of data) when the amount of data to render is large and the control renders for a long time. This data should be cached in the UI control. 1.3 Why to cache data