CI Framework Learning VI (database query cache optimization)

Source: Internet
Author: User

There is a better query optimization in the CI framework, that is, the database cache optimization


1. Turn on caching

Open $db in application/config.php [' Default '] [' cache_on '] = true;//open $db[' default ' in application/config.php Cachedir '] = './cache ';//and add a writeable cache directory to the corresponding directory cache

2. Open the cache statement in the corresponding query


3. Add the appropriate empty cache

Cache is not automatically deleted only manually//So you can clear the cache in the corresponding add-in DELETE statement//Clear All cache $this->db->cache_delete_all ()//Empty a single cache example.com/ Index.php/blog/comments page, the cache system will put all the generated cache files in a folder named Blog+comments. If you want to delete the corresponding cache file for the example mentioned earlier, you need to execute the following code: */$this->db->cache_delete ('/blog ', ' comments ');




CI Framework Learning VI (database query cache optimization)

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.