Data caching for Web applications at the Business Layer

Source: Internet
Author: User
Recently, a web project used a lot of custom data, some of which were saved in XML files and some of which were saved in databases. After the system was officially used, in fact, it will not change frequently, but it will be used frequently. A natural idea is to put the data into the cache, which can greatly improve the efficiency. however, I haven't found a way to use cache on the business layer for a long time. the business layer uses the single-piece mode to put the data to be cached into an arraylist. When used, if the data in the arraylist is empty, it will retrieve the data again and provide a method to clear it, create a cache based on the dependent configuration file on the pages of the data to be used in the web layer, and provide a callback function. When the configuration file changes, clear the arrarylist data, re-create the cache (the original cache has expired. If you want to create it again next time, you only need to create it again ). obviously, this is abnormal, which not only destroys the original Concise structure, but also adds more work. unhappy. fortunately, I finally found it. for ASP.. NET environment, you can use the system. web. httpruntime. cache to access the cache. With this, everything is easy to do. Just move the cache creation directly to the business.

It is a pity that the data in the database cannot be cached using this method (of course, the single-piece mode and the auxiliary method can be used to improve the efficiency, but it is awkward. under X, the cache only provides time-based, keyword-based, and file creation dependencies. The good news is that in 2.0, the database-based creation of cache Dependencies has been provided, and we are eager to look forward to vs2005!

In addition, system. web. httpruntime. appdomainappvirtualpath is used to find the virtual directory of the current application, system. web. httpcontext. current and page in the page background. context is equivalent, and may be useful in many cases. however, if these methods are used at the underlying layer, the coupling between components is added, and these components can only be used on the web.

If other friends have a good way or method, please advise.
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.