WisDom. net Development Framework Design (data cache design)

Source: Internet
Author: User

Why do we need data to be cached in wisDom.net? Our data is divided into two types: 1. dynamic data. This type of data is characterized by great changes. This type of data has a large amount of data. Frequent changes 2. static data is characterized by small changes and frequent use. For example, user, role, permission, role, and other data. Therefore, we cache this part of data into the data at the beginning of the system startup. 2. cache Advantages 1. significantly reduced the number of queries to the database. Improve data access speed 2. improve data stability and availability. If there is a problem with the database, the program can still use cached data. net Cache Technology 4. wisDom. net implementation in WisDom. the Global static variables we selected in. net to implement caching. See the following class diagram and the code of DataCacheCoomon, for details, refer to the copy code public abstract class DataCacheCoomon <T> {protected static List <T> DataCacheDict = null; private static object _ obj = new object (); public DataCacheCoomon () {if (DataCacheDict = null) {lock (_ obj) {if (DataCacheDict = null) {DataCacheDict = new List <T> ();}}}} protected abstract void GetDataFromDb (); /// <summary> /// add data cache /// </summary> /// <param name = "dataItem"> </param> public void AddDataCache (T dataItem) {DataCacheDict. add (dataItem );} /// <summary> /// Delete the data cache /// </summary> /// <param name = "dataItem"> </param> public void DelDataCache (T dataItem) {DataCacheDict. remove (dataItem );} /// <summary> /// obtain the dictionary cache /// </summary> /// <returns> </returns> public List <T> GetDataCacheDict () {return DataCacheDict ;}}

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.