Call Us Today! 877.742.2583

Page tree
Skip to end of metadata
Go to start of metadata


mod_memcache implements an API interface to memcached which is a "high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load."

This module can be used to distribute key/value pairs without having to resort to using ODBC and a database.


 Click here to expand Table of Contents


mod_memcache requires one to have at least one memcached server running to be useful.


To use mod_memcache:

Tell FreeSWITCH to compile in this module by editing modules.conf in the root of your freeswitch source tree and uncomment:

Now go recompile FreeSWITCH.

Tell FreeSWITCH to actually use the memcache module when running by adding the module to modules.conf.xml in /usr/local/freeswitch/conf/autoload_configs:

Finally, edit the default config in the autoload_configs directory to hold your memcache connection information.

Now load up FreeSWITCH!


From the commandline issue something similar to:

which would respond with something like:
This verifies that you are actually communicating with your memcache servers.

Dialplan Application

The memcache API can be called from the dialplan using the ${api(args)} method. Some examples:


The API can be called via ESL or used directly from fs_cli. There is pretty much a 1-1 relationship between the api below and the api exposed via libmemcached.

Sharing Data With Other Applications

This is also very useful to share data across applications. Here an example how to share data between FreeSWITCH and a ruby memcache-client:

On Ruby/Rails set the namespace e.g. to "freeswitch" for the same memcached server in environment.rb

In FreeSWITCH add the following line to the dialplan:

Take care to prefix your key (here "test") with the Ruby namespace "freeswitch:".

Now you can receive the data in Ruby in raw mode:

The 0 as second parameter is important for the raw mode, otherwise ruby will try to marshall the result from memcached and fails.