I'm creating dynamic PNG images from database data using Intervention/image. To decrease the processing load, i'm caching the generated data - using Laravel's Cache driver, set to the default "file". It's also being used for other things, like RSS feeds, or static data that doesn't require a DB call.
I've just switched to the Memcached driver, and everything works - BUT the image data storage. Calls to Cache::get() or Cache::put() using the memcache driver just time out and don't respond.
Example to set the image data, which takes the generated contents of the dynamic PNG and sticks them in the cache:
Cache::put('doc-'.$id, $image->encode('png'), Config::get('def.placeholder_expiry'));
Then, to retrieve it later:
if( Cache::has('doc-'.$id) ) { // key for the image data
$headers = Array(
'Content-Type' => 'image/png',
'Cache-Control' => 'max-age=37739520, public',
'Pragma' => 'Public',
'Expires' => 'Thu, 15 Apr '.(date('Y')+10).' 20:00:00 GMT',
'Content-Disposition' => 'inline; filename=doc-placeholder-cached-'.$id
);
return Response::make(Cache::get('doc-'.$id), 200, $headers);
}
All that works fine with the file cache, but Memcached hates it.
Any ideas? I've losing hair!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community