Skip Navigation
Show nav
Heroku Dev Center Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
Heroku Dev Center Dev Center
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
    • .NET
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log in or Sign up
View categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Buildpacks
    • Platform Principles
  • Developer Tools
    • Command Line
    • Heroku VS Code Extension
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery & Integration (Heroku Flow)
    • Continuous Integration
  • Language Support
    • Node.js
      • Working with Node.js
      • Node.js Behavior in Heroku
      • Troubleshooting Node.js Apps
    • Ruby
      • Rails Support
        • Working with Rails
      • Working with Bundler
      • Working with Ruby
      • Ruby Behavior in Heroku
      • Troubleshooting Ruby Apps
    • Python
      • Working with Python
      • Background Jobs in Python
      • Python Behavior in Heroku
      • Working with Django
    • Java
      • Java Behavior in Heroku
      • Working with Java
      • Working with Maven
      • Working with Spring Boot
      • Troubleshooting Java Apps
    • PHP
      • Working with PHP
      • PHP Behavior in Heroku
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
    • .NET
      • Working with .NET
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
      • Migrating to Heroku Postgres
    • Heroku Key-Value Store
    • Apache Kafka on Heroku
    • Other Data Stores
  • AI
    • Working with AI
    • Heroku Inference
      • AI Models
      • Heroku Inference Quick Start Guides
      • Inference Essentials
      • Inference API
    • Tool Use
    • Vector Database
    • AI Integrations
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
      • Single Sign-on (SSO)
    • Private Spaces
      • Infrastructure Networking
    • Compliance
  • Heroku Enterprise
    • Enterprise Accounts
    • Enterprise Teams
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
    • Heroku AppLink
      • Heroku AppLink Reference
      • Working with Heroku AppLink
      • Getting Started with Heroku AppLink
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
    • Other Salesforce Integrations
  • Add-ons
  • All Add-ons
  • Pure Memcache
Pure Memcache

This add-on is operated by Pure Serv Partners

Pure Performance, Pure Value

Pure Memcache

Last updated October 01, 2025

The Pure Memcache add-on is currently in beta.

Table of Contents [expand]

  • Provisioning the Add-on
  • Using Pure Memcache from Ruby and Rails
  • Using Pure Memcache from Node.js
  • Using Pure Memcache from Python
  • Using Pure Memcache from Java
  • Using Pure Memcache from PHP
  • Migrating Between Plans
  • Removing the Add-on
  • Support

Pure Memcache is an add-on for adding Memcached servers to your Heroku application. The built-in functionality offers fault-tolerant caching by spreading the load across different server instances and availability zones.

Provisioning the Add-on

Pure Memcache offers several plans with different cache sizes. The Value tier is the most cost-effective, while the Performance tier offers faster speed.

Attach Pure Memcache to a Heroku application via the CLI:

Reference the Pure Memcache Elements Page for a list of available plans and regions.

$ heroku addons:create pure-memcache:value1
Creating pure-memcache on example-app... free
Your add-on has been provisioned successfully

After provisioning Pure Memcache, the following config vars are available in the attached app’s configuration:

  • PURE_MEMCACHE_SERVERS
  • PURE_MEMCACHE_USERNAME
  • PURE_MEMCACHE_PASSWORD

You can see the config var via the heroku config:get command:

$ heroku config:get PURE_MEMCACHE_SERVERS

After installing Pure Memcache, the application is fully configured to integrate with the add-on.

The Pure Memcache servers aren’t set up to use encryption, as it slows the caching. We recommend not using Pure Memcache for confidential data.

Using Pure Memcache from Ruby and Rails

Use the Dalli gem to connect to Pure Memcache:

In your Gemfile add:

gem 'dalli'

Then run:

$ bundle install

You can then access Memcache with:

require 'dalli'
cache = Dalli::Client.new(ENV['PURE_MEMCACHE_SERVERS'].split(','),
  {username: ENV['PURE_MEMCACHE_USERNAME'], password: ENV['PURE_MEMCACHE_PASSWORD']})

Rails

After installing the Dalli gem, you can edit the config/environments/production.rb file to use Pure Memcache as your default Rails cache:

config.cache_store = :mem_cache_store, ENV['PURE_MEMCACHE_SERVERS'].split(','),
  {username: ENV['PURE_MEMCACHE_USERNAME'], password: ENV['PURE_MEMCACHE_PASSWORD']}

Using Pure Memcache from Node.js

Use the memjs package to access Pure Memcache from Node.js:

$ npm install memjs

Then you can create a client:

const memjs = require('memjs'); // or import memjs from 'memjs' if using ES modules

const client = memjs.Client.create(process.env.PURE_MEMCACHE_SERVERS, {
  username: process.env.PURE_MEMCACHE_USERNAME,
  password: process.env.PURE_MEMCACHE_PASSWORD,
  failover: true
});

Using Pure Memcache from Python

Use the bmemcached module to access Pure Memcache from Python.

First, install the module:

$ pip install python-binary-memcached

Then the you can create a client:

import os
import bmemcached

client = bmemcached.Client(os.environ.get('PURE_MEMCACHE_SERVERS').split(','), os.environ.get('PURE_MEMCACHE_USERNAME'), os.environ.get('PURE_MEMCACHE_PASSWORD'))

Using Pure Memcache from Java

Use the XMemcached client to access Pure Memcache from Java.

First, add the XMemcached library to your Project Object Model file or pom.xml:

<dependency>
  <groupId>com.googlecode.xmemcached</groupId>
  <artifactId>xmemcached</artifactId>
  <version>2.4.8</version>
</dependency>

Then you can create a XMemcached client:

List<InetSocketAddress> servers = AddrUtil.getAddresses(System.getenv("PURE_MEMCACHE_SERVERS").replace(",", " "));
AuthInfo authInfo = AuthInfo.plain(System.getenv("PURE_MEMCACHE_USERNAME"), System.getenv("PURE_MEMCACHE_PASSWORD"));

MemcachedClientBuilder builder = new XMemcachedClientBuilder(servers);
for (InetSocketAddress server : servers) builder.addAuthInfo(server, authInfo);

// Must use binary protocol
builder.setCommandFactory(new BinaryCommandFactory());
MemcachedClient client=builder.build();

Using Pure Memcache from PHP

Use the PHP Memcached Client to connect from PHP.

First, add the following to your composer.json file:

"require": {
    "ext-memcached": "*"
}

Then run:

$ composer update

Then you can create a Memcached client:

$client = new Memcached();
$client->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
// use consistent hashing to allow adding or removing of servers without losing cached values
$client->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
$client->setOption(Memcached::OPT_DISTRIBUTION, Memcached::DISTRIBUTION_CONSISTENT);
// failover
$client->setOption(Memcached::OPT_REMOVE_FAILED_SERVERS, true);
// this should only be called once to avoid adding the servers multiple times...
$client->addServers(array_map(fn($server) => explode(':', $server, 2), explode(',', $_ENV['PURE_MEMCACHE_SERVERS'])));
$client->setSaslAuthData($_ENV['PURE_MEMCACHE_USERNAME'], $_ENV['PURE_MEMCACHE_PASSWORD']);

Migrating Between Plans

Application owners must carefully manage the migration timing to ensure proper application function during the migration process.

You can only upgrade and downgrade plans within the same tier as the Value and Performance tiers are implemented on completely different servers. To minimize the impact of upgrades and downgrades within a tier on your production environment, we recommend changing to the next nearest plan in size. By changing plans gradually over time, you can ensure the impact on your live service is minimal.

Use the heroku addons:upgrade command to migrate to a new plan.

$ heroku addons:upgrade pure-memcache:value2
-----> Upgrading pure-memcache:value 2 to example-app.. done, v18 ($49/mo)
       Your plan has been updated to: pure-memcache:value 2

Removing the Add-on

Remove Pure Memcache via the CLI:

This action destroys all associated data and you can’t undo it!

$ heroku addons:destroy pure-memcache
-----> Removing pure-memcache from example-app... done

Support

Submit all Pure Memcache support and runtime issues via one of the Heroku Support channels. Any non-support-related issues or product feedback is welcome at feedback@pureserv.link.

Keep reading

  • All Add-ons

Feedback

Log in to submit feedback.

Zara 4 Pusher Channels

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure
  • .NET

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing
  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Github
  • LinkedIn
  • © 2025 Salesforce, Inc. All rights reserved. Various trademarks held by their respective owners. Salesforce Tower, 415 Mission Street, 3rd Floor, San Francisco, CA 94105, United States
  • heroku.com
  • Legal
  • Terms of Service
  • Privacy Information
  • Responsible Disclosure
  • Trust
  • Contact
  • Cookie Preferences
  • Your Privacy Choices