Cache images generated by gd to memcahe_PHP tutorial

Source: Internet
Author: User
Cache the image generated by gd to memcahe. Print? Start to cache the image ob_start (); enable the output cache, and temporarily cache the output content imagejpeg ($ newimage, false, $ quality); output $ dataob_get_contents (); get the print? // Start to cache images

Ob_start (); // enable the output cache to temporarily cache the output content

Imagejpeg ($ newimage, false, $ quality); // output

$ Data = ob_get_contents (); // Obtain the cache you just obtained

Ob_end_clean (); // clear the cache

$ Mem = get_memcache (); // modify it by yourself

$ Mem-> set ($ mem_key, $ data, 720000); // Save the obtained output to memcache.

Echo $ data; // output image

And then display it like this.

$ Mem = get_memcache (); // modify it by yourself
$ Data = $ mem-> get ($ mem_key );

If ($ data ){

Echo $ data;

Exit ();

}

Http://www.bkjia.com/PHPjc/477491.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/477491.htmlTechArticleprint? // Start to cache the image ob_start (); // enable the output cache and temporarily cache the output content imagejpeg ($ newimage, false, $ quality ); // Output $ data = ob_get_contents (); // get just...

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.