Links: Homepage | Documentation
Dependencies: Libevent
Version: 1.4.15

Memcached is an in-memory key-value store for small chunks of arbitrary data.

Get the Code

Switch to /usr/local/src and download the source package.

cd /usr/local/src
curl --remote-name

Extract the archive and move into the folder.

tar -xzvf memcached-VERSION.tar.gz
cd memcached-VERSION

Compile and Install

Configure, compile and install into /usr/local/memcached-VERSION.

./configure --prefix=/usr/local/memcached-VERSION --with-libevent=/usr/local/libevent/
make install

Create a symbolic link that points /usr/local/memcached to /usr/local/memcached-VERSION.

ln -s memcached-VERSION /usr/local/memcached


Execute the following lines to update your Bash startup script.

echo 'export PATH=/usr/local/memcached/bin:$PATH' >> ~/.bash_profile
echo 'export MANPATH=/usr/local/memcached/share/man:$MANPATH' >> ~/.bash_profile

Load the new shell configurations.

source ~/.bash_profile

Manual Start/Stop

To start the Memcached server.

memcached -vv

Press CTRL-C to stop the Memcached server.

Automatically Start the Server at Boot

Create a configuration file for Launchd.

nano ~/Library/LaunchAgents/org.memcached.memcached.plist

Copy and paste the following text into the aforementioned file.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">




Register with Launchd and start the server.

launchctl load -w ~/Library/LaunchAgents/org.memcached.memcached.plist

Deregister with Launchd. Kill the process manually.

launchctl unload -w ~/Library/LaunchAgents/org.memcached.memcached.plist

Verify the Installation

Display the Memcached version.

memcached -h

Using the Memcached Telnet Interface

You can connect to the Memcached server with Telnet.

telnet localhost 11211

To test if everything is working correctly, set a cache item.

set foo 0 900 5

To retrieve the cache item.

get foo

To exit the Telnet session.


For more information on using Memcached Telnet commands.