Support the ongoing development of Laravel.io →
Configuration Requests Cache

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!

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

azcoppen azcoppen Joined 15 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.