Enabling Memcached in MAMP4

Make it Speedy!

Categories: Development, WordPress

I do all of my Laravel and WordPress locally using MAMP. I like to keep my development process as simple as possible and MAMP lets me do just that. But sometimes you need just a little bit more than what comes out of the box. Caching is an important part of that development cycle and for that I like to use Memcached.

Getting Memcached running with MAMP is a lot more straightforward than it used to be but there are still a few gotchas.

First of all, you will need to install Memcached and since OS X doesn’t have a package manager I like to use [Homebrew]https://brew.sh/). Run brew install memcached.

Next you will need to enable Memcached in your php.ini located /Applications/MAMP/bin/php/php7.x,x/conf/php.ini, x.x being the version of PHP that you are running.

Search for ; Extensions and add or uncomment the following.


Now that MAMP setup you can run it as a daemon in the background from the terminal.

memcached -d

Restart MAMP and you’re off to the races!


In order to use Memcached with Laravel simply open the config/cache.php file and modify your Memcached settings ( in my case default worked fine ).

'memcached' => [
        'host' => '',
        'port' => 11211,
        'weight' => 100

Now you could do something like this:

if (Cache::has('key')):
    return Cache::get('key');
    $data = ['some' => 'data'];
    Cache::put('key', $data, 15);
    return $data;

If our key is set then we can pull from the cache and return the value, otherwise add it to cache and save it for 15 minutes. Using caching effectively will allow your applications to be tuned and performance will go up. Testing and improving performance with WordPress is especially important due to its bloated and often clunky implementations and different ideologies.

Adam Patterson

Adam Patterson

User Interface Designer & Developer with a background in UX. I have spent 5 years as a professionally certified bicycle mechanic and ride year-round.

I am a husband and father of two, I enjoy photography, music, movies, coffee, and good food.

You can find me on Twitter, Instagram, and YouTube!