Skip Navigation
Show nav
Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • 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 inorSign up
Hide categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • 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 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
      • PHP Behavior in Heroku
      • Working with PHP
    • 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
      • Inference API
      • Quick Start Guides
      • AI Models
      • Inference Essentials
    • Vector Database
    • Model Context Protocol
  • 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
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
  • 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
  • Add-ons
  • All Add-ons
  • Stackhero for Memcached
Stackhero for Memcached

This add-on is operated by Stackhero

Memcached on dedicated instances, up-to-date versions and attractive prices

Stackhero for Memcached

Last updated October 10, 2024

Table of Contents

  • Provisioning the Add-on
  • Local Setup
  • Connect to the Stackhero Dashboard
  • Connecting to Memcached
  • Configure Memcached on Ruby
  • Upgrading your Plan
  • Removing the Add-on
  • Support
  • Additional Resources

The Stackhero for Memcached add-on provides a managed Memcached running on a fully dedicated instance. It provides the following features:

  • A private instance (dedicated VM) for high performances and security
  • TLS encryption (aka SSL)
  • An automatic backup every 24 hours
  • One click to update to new Memcached versions

Provisioning the Add-on

Stackhero for Memcached can be attached to a Heroku application via the CLI:

A list of all plans available can be found here.

$ heroku addons:create ah-memcached-stackhero --app <your app name>
-----> Adding ah-memcached-stackhero to sharp-mountain-4005... done

After you provision Stackhero for Memcached, multiple config variables are available in your app’s configuration:

  • STACKHERO_MEMCACHED_HOST
  • STACKHERO_MEMCACHED_PORT_TLS
  • STACKHERO_MEMCACHED_PORT_CLEAR
  • STACKHERO_MEMCACHED_USER
  • STACKHERO_MEMCACHED_PASSWORD

You can see the content of these variables via the heroku config:get command:

$ heroku config:get STACKHERO_MEMCACHED_HOST
$ heroku config:get STACKHERO_MEMCACHED_PORT_TLS
$ heroku config:get STACKHERO_MEMCACHED_PORT_CLEAR
$ heroku config:get STACKHERO_MEMCACHED_USER
$ heroku config:get STACKHERO_MEMCACHED_PASSWORD

Local Setup

After you provision the add-on, you must replicate its config variables locally.

Use the Heroku Local command-line tool to configure, run, and manage process types specified in your app’s Procfile. Heroku Local reads configuration variables from an .env file. To view all of your app’s config variables, type heroku config. Use the following command for each value you want to add to your .env file:

heroku config:get <STACKHERO_MEMCACHED_VARIABLE> -s  >> .env

For example:

$ heroku config:get STACKHERO_MEMCACHED_HOST >> .env
$ heroku config:get STACKHERO_MEMCACHED_PORT_TLS >> .env
$ heroku config:get STACKHERO_MEMCACHED_PORT_CLEAR >> .env
$ heroku config:get STACKHERO_MEMCACHED_USER >> .env
$ heroku config:get STACKHERO_MEMCACHED_PASSWORD >> .env

Don’t commit credentials and other sensitive configuration values to source-control. In Git, exclude the .env file with: echo .env >> .gitignore.

For more information, see Heroku Local.

Connect to the Stackhero Dashboard

Stackhero dashboard allows you to see your instance usage, restart it, and apply updates. You can access the dashboard via the CLI:

$ heroku addons:open ah-memcached-stackhero
Opening ah-memcached-stackhero for sharp-mountain-4005

You can also visit the Heroku Dashboard, select your application, and then select Stackhero for Memcached from the Add-ons menu.

Connecting to Memcached

We recommend you use TLS encryption when connecting to Memcached. Use the following environment variables to connect:

  • STACKHERO_MEMCACHED_HOST
  • STACKHERO_MEMCACHED_PORT_TLS
  • STACKHERO_MEMCACHED_PORT_CLEAR
  • STACKHERO_MEMCACHED_USER
  • STACKHERO_MEMCACHED_PASSWORD

Configure Memcached on Ruby

First, install the “dalli” and “openssl” gem:

$ bundle add dalli openssl

Then, edit the config/environments/production.rb file and add this code:

require "openssl"
ssl_context = OpenSSL::SSL::SSLContext.new
ssl_context.verify_hostname = true
ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER
ssl_context.ca_path = "/etc/ssl/certs"

config.cache_store = :mem_cache_store,
                    ENV["STACKHERO_MEMCACHED_HOST"] + ":" + ENV["STACKHERO_MEMCACHED_PORT_TLS"],
                    {
                      :username => ENV["STACKHERO_MEMCACHED_USER"],
                      :password => ENV["STACKHERO_MEMCACHED_PASSWORD"],
                      :ssl_context => ssl_context
                    }

For more informations about configuring Memcached as a cache system for Ruby on Rails, you can consult the official Rails documentation here.

By default caching is only enabled on production environment.

If you need to test caching on development, edit the file config/environments/development.rb, add the configuration from above and add config.action_controller.perform_caching = true to enable caching.

A good way to test that caching works is to start a Rails console (with bin/rails console) and test writing with Rails.cache.write("foo", "bar").

Upgrading your Plan

You can’t downgrade an existing add-on.

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

$ heroku addons:upgrade ah-memcached-stackhero:newplan
-----> Upgrading ah-memcached-stackhero:newplan to sharp-mountain-4005... done
       Your plan has been updated to: ah-memcached-stackhero:newplan

Manage migration timing to ensure your application is available during the migration process.

Removing the Add-on

You can remove Stackhero for Memcached via the CLI:

This will destroy all associated data and can’t be undone!

$ heroku addons:destroy ah-memcached-stackhero
-----> Removing ah-memcached-stackhero from sharp-mountain-4005... done

Support

Stackhero for Memcached support and runtime issues should be submitted via one of the Heroku Support channels. We recommend adding support@stackhero.io in copy for urgent issues.

Additional Resources

  • Memcached documentation by Stackhero
  • Memcached managed cloud

Keep reading

  • All Add-ons

Feedback

Log in to submit feedback.

Zara 4 Stackhero for Mercure-Hub

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