Microsoft Enterprise Library-Design and Analysis of interpreting Cache

Source: Internet
Author: User

Microsoft Enterprise Library-Design and Analysis of interpreting Cache

 

The role and design of the cache application block have been clearly stated in the msdn article. This article aims to further dissect the cache application block and describe its class blueprint and main process.

"Although the sparrow is small, it seems that it is not worth studying for a small application such as cache. In fact, it is not the case that the cache has given me a lot of inspiration and its architecture, design and coding.

1. the cache can be divided into the following parts:


As you can see,

1.1 The Ache Application Block is configured based on the driver, and the configuration is read through the configuration application block. 1.2 The Cache Policy scheduling class package is used for expiration management and cache Size Policy Management. Expiration management regularly scans all cacheitems of the cache and determines whether the cache expires Based on the expiration set that comes with each cacheitem, if it expires, the cache expiration process will be called. Cache Size Policy Management is triggered when each cacheitem is added to determine whether the cache has reached the threshold to be cleared. If this parameter is exceeded, the number of cacheitems is cleared.

1.3 The cache background storage package is used to solve the availability of the cache program block. When the data source is unavailable, the application can continue to be available based on the background storage data.

1.4 The cache service package is a class that deals with system administrators (including WMI, performance counters, and Eventlog. These classes send the current running status data of the cache application to the system administrator. This allows users to learn about the running status of the current cache through the system administrator.

 

2 cache application blocks have the following features:

2.1 The same design pattern as several other application blocks in the Enterprise Library. To improve the flexibility and scalability of the program block, users can obtain cachemanager and backingstore through configuration. The program block uses the factory class to provide specific cachemanager and backingstore through configuration, you can use ibackingstore to expand backingstore. You can store backend data in databases, XML files, and file systems ....

2.2 adopt interface-based programming. The interface defines specifications and behaviors. For example, icacheitemexpiration is an interface used for cacheitem expiration. In addition to several expiration classes customized by the system, you can define the expiration by yourself.

For another example, icacheitemrefreshaction is the interface that cacheitem performs after it expires and is removed, so that you can customize the behavior after cacheitem expires.

2.3 system performance monitoring mechanism. Because the cache needs to occupy memory while the memory is limited, you cannot estimate how much memory the cache will occupy before the system runs. If the cache running status is not monitored, the system will often crash due to the unlimited increase in the cache volume. Therefore, cache provides a sound monitoring mechanism. This allows you to monitor the cache status during system operation so that you can adjust the expiration Policy and Size Policy in a timely manner.

 

3. the class diagram of the cache application block is as follows:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.