Develop a web application using EF (4): cache query string

Source: Internet
Author: User

Question:There is no precedent for developing Web applications with "easy language. Flying" (EF. However, because the EF Local Development Kit (efndk) has been released, it is not difficult to use C/C ++ to develop an EF class library to support EF in developing web applications. Of course, we can imagine that there are many difficulties to solve. This series of articles is a record of my exploration process and may not be of much value to outsiders. If some netizens are optimistic about it, please wait rationally. Author: liigo. For more information, see http://blog.csdn.net/liigo /. Online messages.

 

Develop a web application using EF (4): cache query string

 

The previous article has discussed how to read query strings. We will continue to discuss optimization measures related to query string today.

In cgi/FastCGI programs, query string is the most important and frequently used parameter. Its main operations include: 1. Reading query string from environment variables; 2. perform URL Decoding on the query string. 3. parse the parameter value of the specified name from the query string. These three operations are relatively time-consuming, and the most common 3rd operations depend on the first two operations.

In the "easy language. Flying" class library FastCGI. efn, I have specially optimized the query string, effectively improving the program execution efficiency. The main optimization measure is cache: during each request (request), the data can be read only once from the environment variable at most, and the data can be decoded only once, only the decoded query string can be parsed once at most. At the same time, the parsed results are placed in the hash table to further improve the retrieval efficiency. (The implementation details may be worth noting that the hash table I use here is case sensitive when comparing text. This requires users to be case sensitive when using the parameter text, otherwise, no correct results will be obtained. I think this is not very demanding, because both C/C ++ and EF are case sensitive at the language level. programmers should not make low-level mistakes in this regard, in addition, the execution efficiency of case-sensitive text is higher than that of case-insensitive text. Of course, this behavior may be adjusted as necessary in the future. Todo: see rfc1738 .)

If you are still surprised by the code "fcgi = new fcgi ();", wondering why not define all methods in the fcgi class as static methods, now you can find some answers. By the way, the optimization needs. Before entering the fcgi. Accept () loop, creating an EF object does not affect the execution efficiency of the FastCGI program, but can optimize the execution efficiency to a large extent. Why not?

 

Next article: URL encoding and URL Decoding

 

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.