Microsoft enterprise database 4.1 Study Notes (19th) cache Module 7. Expand and modify the cache Module

Source: Internet
Author: User

The cache module can meet most of the Cache Usage situations. However, you still want to customize some module behaviors to meet the special requirements of applications. You can achieve this in two ways:

    • Extends existing functions through the extension points provided by the cache Module
    • ModifySource code

I. Extended cache Module

Extend the functions of the application by designing the extension points. A typical method is to write a custom class, implement an interface, or inherit an abstract class. Because these custom classes are used in your application, you do not need to modify or re-compile the module.

You can customize a new backend storage method, add an expiration policy, or a new cachemanager.

1.1 Add a new backend storage

Add a new class to implement the ibackingstore interface or inherit from the basebackingstore class. You must ensure that the back-end storage is still intact and can provide services when you access the back-end storage.

Because it is a cache operation, it can ensure that any operation on the backend storage is a single thread. This means you do not need to consider thread security during implementation.

1.2 Add a new expiration Policy

To implement a new expiration policy, you need to add classes to implement the following interface:

    • Icacheitemexpiration, which allows developers to define their own expiration rules and how and when a cache item cacheitem expires.
    • Icacheitemrefreshaction. After expiration, the cache can be updated. classes that implement this interface must be serializable.

1.3 change the default cachemanager

Cachemanager in the cache module implements the icahemanager interface. When the system is initialized, cachemanager loads data from the backend storage to the memory. by exposing the data, it can add and delete items to obtain cached data.

Although the default cachemanager can meet the needs of most applications, it is possible that when your application has special requirements, you can implement your own cachemanager to modify the behavior of the cache module. The following lists some features you may need:

Implementing a distributed or special caching method supports different solutions, not only to store and retrieve data, but also to add Custom backend storage.

Change the way in which the cachemanager loads data to the memory. Load only the most commonly used items, or minimize the number of add-ons as required.

To create a custom cachemanager, you must implement the icachemanager interface and add the following features to inform the configuration system that the cachemanager class can be installed and configured.

[Configurationelementtype (typeof (mcmcachemanagerdata)]

Ii. Modify the module

If you need to modify the module to meet some special requirements of the application, refer to the following instructions:

    • Make sure that you understand the running of the module and read the relevant documents.
    • If you need to add new functional modules and run them together with some original modules, you 'd better modify the module namespace and the corresponding module namespace.
    • Use a signature to ensureProgramUniqueness of a set
    • After modification, remember to recompileCode
Related Article

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.