Memcached Cloud
Last updated July 11, 2025
Table of Contents
Memcached Cloud (part of Redis Cloud) is a fully managed cloud service for running your Memcached databases. You can quickly and easily get your apps up and running with Memcached Cloud through its add-on for Heroku - tell us how much memory you need and get started fast with your first Memcached database. You can then add more Memcached databases and increase or decrease the memory size of your plan without affecting your existing data.
Memcached Cloud offers true high availability with its in-memory dataset replication and instant auto-failover mechanism. Memcached Cloud provides various data persistence options as well as remote backups for disaster recovery purposes.
Get started
Select Install Memcached Cloud to install the Memcached Cloud add-on.
You can also use the Heroku command-line interface to install Redis Cloud. Run the following heroku
command to install the add-on and create a Free 30MB database.
$ heroku addons:create memcachedcloud
You can also specify the plan size by adding the plan size in MB. For example, run the following command to install the add-on and create a 1GB database.
$ heroku addons:create memcachedcloud:1000
A list of all available plans can be found here.
Once Memcached Cloud has been added, you will notice three new config vars in your heroku
environment containing the servers, username and password of your first Memcached Cloud bucket:
MEMCACHEDCLOUD_SERVERS
, MEMCACHEDCLOUD_USERNAME
, and MEMCACHEDCLOUD_PASSWORD
. Run heroku config
to see the config vars.
Connect to your database
You can connect to your database with any Memcached client that supports SASL authentication.
The following sections show how to connect with these languages and frameworks:
- Ruby with
Dalli
- Java with
spymemcached
- Python with
bmemcached
- PHP with PHP Memcached
- Node.js with
MemJS
Connect with Ruby
Dalli is a high performance, pure Ruby client for accessing Memcached servers that uses binary protocol.
To use Dalli with Rails 3.x, update your gems with:
gem 'dalli'
And then install the gem via Bundler:
bundle install
Lastly, add the following line in your config/environments/production.rb
:
if ENV["MEMCACHEDCLOUD_SERVERS"]
config.cache_store = :mem_cache_store, ENV["MEMCACHEDCLOUD_SERVERS"].split(','), { :username => ENV["MEMCACHEDCLOUD_USERNAME"], :password => ENV["MEMCACHEDCLOUD_PASSWORD"] }
end
Configure Memcached on Sinatra
Add this code snippet to your configure block:
configure do
. . .
require 'dalli'
if ENV["MEMCACHEDCLOUD_SERVERS"]
$cache = Dalli::Client.new(ENV["MEMCACHEDCLOUD_SERVERS"].split(','), :username => ENV["MEMCACHEDCLOUD_USERNAME"], :password => ENV["MEMCACHEDCLOUD_PASSWORD"])
end
. . .
end
Use Memcached on Unicorn
No special setup is required when using Memcached Cloud with a Unicorn server. Users running Sinatra apps on Unicorn should follow the instructions in the Configure Memcached on Sinatra section.
Testing (Ruby)
$cache.set("foo", "bar")
# => true
$cache.get("foo")
# => "bar"
A Sinatra sample application is available at GitHub.
Browse the source code or
Connect with Java
spymemcached is a simple, asynchronous, single-threaded Memcached client written in Java. You can download the latest build from: https://code.google.com/p/spymemcached/downloads/list.
If you are using Maven
, start by adding the following repository:
<repositories>
<repository>
<id>spy</id>
<name>Spy Repository</name>
<layout>default</layout>
<url>http://files.couchbase.com/maven2/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
Then, specify the actual artifact as follows:
<dependency>
<groupId>spy</groupId>
<artifactId>spymemcached</artifactId>
<version>2.8.9</version>
<scope>provided</scope>
</dependency>
Configure the connection to your Memcached Cloud service by using the environment variables as shown in the following code snippet:
try {
AuthDescriptor ad = new AuthDescriptor(new String[] { "PLAIN" },
new PlainCallbackHandler(System.getenv("MEMCACHEDCLOUD_USERNAME"), System.getenv("MEMCACHEDCLOUD_PASSWORD")));
MemcachedClient mc = new MemcachedClient(
new ConnectionFactoryBuilder()
.setProtocol(ConnectionFactoryBuilder.Protocol.BINARY)
.setAuthDescriptor(ad).build(),
AddrUtil.getAddresses(System.getenv("MEMCACHEDCLOUD_SERVERS")));
} catch (IOException ex) {
// the Memcached client could not be initialized.
}
Testing (Java)
mc.set("foo", 0, "bar");
Object value = mc.get("foo");
A Java sample application, running on Play!, is available at GitHub.
Browse the source code or
Connect with Python
bmemcached is a pure, thread safe, python module to access memcached via binary protocol.
Use pip
to install it:
$ pip install python-binary-memcached
Configure the connection to your Memcached Cloud service using the MEMCACHEDCLOUD
config vars and the following code snippet:
import os
import urlparse
import bmemcached
import json
mc = bmemcached.Client(os.environ.get('MEMCACHEDCLOUD_SERVERS').split(','), os.environ.get('MEMCACHEDCLOUD_USERNAME'), os.environ.get('MEMCACHEDCLOUD_PASSWORD'))
Testing (Python)
mc.set('foo', 'bar')
print client.get('foo')
Connect with PHP
PHP Memcached ensures efficient performance as well as advanced features on top of the core memcached functions.
Heroku’s PHP environment supports it as a third party extension - just add the following module to your composer.json
file:
"require": {
"ext-memcached": "*"
}
Next, ensure that your new requirements are “frozen” to composer.lock
by running:
$ composer update
For more information on enabling the extension and potential troubleshooting (e.g. when you don’t have the memcached
extension available on your local computer), refer to the using optional extensions extensions section of Heroku’s PHP reference documentation.
Configure a connection to your Memcached Cloud service using the MEMCACHEDCLOUD
config vars and the following code snippet:
$mc = new Memcached();
$mc->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
$mc->addServers(array_map(function($server) { return explode(':', $server, 2); }, explode(',', $_ENV['MEMCACHEDCLOUD_SERVERS'])));
$mc->setSaslAuthData($_ENV['MEMCACHEDCLOUD_USERNAME'], $_ENV['MEMCACHEDCLOUD_PASSWORD']);
Testing (PHP)
$mc->set('foo', 'bar');
echo $mc->get('foo');
A PHP sample application is available at GitHub.
Browse the source code or
Connect with Node.js
MemJS is a pure Node.js client library for using memcached. It uses the binary protocol and support SASL authentication.
You can install it with:
$ npm install memjs
Configure a connection to your Memcached Cloud service using the following code snippet:
var memjs = require('memjs');
var client = memjs.Client.create(process.env.MEMCACHEDCLOUD_SERVERS, {
username: process.env.MEMCACHEDCLOUD_USERNAME,
password: process.env.MEMCACHEDCLOUD_PASSWORD
});
Testing (Node.js)
client.set("foo", "bar");
client.get("foo", function (err, value, key) {
if (value != null) {
console.log(value.toString()); // Will print "bar"
}
});
A Node.js sample application is available at GitHub.
Browse the source code or
Open Redis Cloud console
The Redis Cloud console lets you make changes to your Memcached database settings, add extra databases to your plan, and view metrics for your databases.
To access the Redis Cloud console and view your Memcached Cloud database, run:
$ heroku addons:open memcachedcloud
Alternatively, open the Memcached Cloud add-on from your application’s dashboard at heroku.com.
From the Redis Cloud console, you can:
Back up your data
By default, Memcached Cloud stores your backups to a default backup repository. To view your backups from the Redis Cloud console, select your database from the database list. In the Configuration tab, under Durability, select View backups.
Select Download to download a backup file.
The default repository only retains daily backups for one week. To learn how to change your backup location, see Back up a database (Redis Cloud docs).
Select Backup now to back up your database manually.
Backups are available only for paid plans.
Add Memcached databases to your plan
For paid plans, Memcached Cloud allows you to add multiple Memcached databases without interfering with your other databases from the Redis Cloud console.
Each plan has a limit for the amount of databases you can create. After you reach the database limit or the memory limit for your plan, you won’t be able to add any more databases.
Your first Memcached database is created automatically upon launching the Memcached Cloud add-on and its servers and credentials are maintained in the MEMCACHEDCLOUD
config vars.
To add more databases from the Redis Cloud console:
- Select Subscriptions from the menu to see your plan with all of its databases.
Select + Create database in this subscription.
Enter the database name and select your new database’s settings.
Select Activate database to activate your new database.
After your new database is ready, you’re able to connect to it. You can find the public endpoint for your new database in the Configuration tab of your database in the General section. The credentials for your new database are available in the Security section.
View database metrics
To view metrics from the Redis Cloud console, select your database from the database list, and then select the Metrics tab.
For more information on the metrics available in the Redis Cloud console, see Monitor database performance (Redis Cloud docs).
Upgrade plan
Upgrading your plan is easy and instant. It requires no code change and has no effect on your existing datasets. You can use the ‘heroku addons:upgrade’ command to upgrade to a new plan.
$ heroku addons:upgrade memcachedcloud:[size_in_mb]
For example, run this command to upgrade to a 5 GB database:
$ heroku addons:upgrade memcachedcloud:5000
Remove the add-on
To remove the Memcached Cloud add-on, run:
This will destroy all data and cannot be reversed.
$ heroku addons:destroy memcachedcloud
Support
All Memcached Cloud support and runtime issues should be submitted via the Heroku Support channels. We recommend also reaching out to Redis support for urgent issues. We are also available on twitter @Redisinc.