Home >Backend Development >PHP Tutorial >Caching images generated by gd to memcahe_PHP tutorial
print?//Start caching images
ob_start();//Enable output caching and temporarily cache the content to be output
Imagejpeg($newimage,false,$quality);//Output
$data = ob_get_contents();//Get the cache just obtained
ob_end_clean();//Clear the cache
$mem =get_memcache();//Modify it yourself
$mem->set($mem_key,$data,720000);//Save the output just obtained into memcache
echo $data;//Output picture
Then it’s displayed like this
$mem = get_memcache();//Modify it yourself
$data = $mem->get($mem_key);
If($data) {
echo $data;
exit();
}