Skip Navigation
Show nav
Heroku Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
  • 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
View categories

Categories

  • Heroku Architecture
    • Dynos (app containers)
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Command Line
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery
    • Continuous Integration
  • Language Support
    • Node.js
    • Ruby
      • Working with Bundler
      • Rails Support
    • Python
      • Background Jobs in Python
      • Working with Django
    • Java
      • Working with Maven
      • Java Database Operations
      • Working with the Play Framework
      • Working with Spring Boot
      • Java Advanced Topics
    • PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
    • Heroku Data For Redis
    • Apache Kafka on Heroku
    • Other Data Stores
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
    • Compliance
  • Heroku Enterprise
    • Private Spaces
      • Infrastructure Networking
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
    • Single Sign-on (SSO)
  • 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
  • Continuous Delivery
  • Flushing a MemCachier Cache on Deployment

This article was contributed by The MemCachier Add-on

MemCachier manages and scales clusters of memcache servers so you can focus on your app. Tell us how much memory you need and get started for free instantly. Add capacity later as you need it.

follow @MemCachier on Twitter

Flushing a MemCachier Cache on Deployment

English — 日本語に切り替える

Last updated May 13, 2020

Table of Contents

  • Step 1: Obtain your MemCachier credentials
  • Step 2: Test out flushing the cache
  • Step 3: Set up a deploy hook
  • Additional resources

The MemCachier add-on provides an HTTP API for flushing its cache contents. This allows you to set up a Heroku HTTP deploy hook that flushes your cache every time you deploy to staging or production, ensuring that your cache is clean and ready to go.

Step 1: Obtain your MemCachier credentials

To communciate with the MemCachier API, you need the values of your app’s MEMCACHIER_USERNAME and MEMCACHIER_PASSWORD config vars. You can obtain these values with the heroku config CLI command, or by looking them up on your MemCachier analytics dashboard.

After you obtain these values, you can use them to obtain your cache’s unique ID. Send the following cURL request, providing your MemCachier username and password where indicated:

$ curl "https://analytics.memcachier.com/api/v1/login" \
> --user "REPLACE_WITH_MEMCACHIER_USERNAME:REPLACE_WITH_MEMCACHIER_PASSWORD"

The body of the API’s response includes your cache’s unique ID:

{
  "cache_id": 123456
}

Step 2: Test out flushing the cache

After you have your MemCachier username, password, and cache ID, you can flush your cache with the following cURL request (substitute your credentials where indicated):

$ curl "https://analytics.memcachier.com/api/v1/REPLACE_WITH_MEMCACHIER_CACHE_ID/flush" \
> -X POST --user "REPLACE_WITH_MEMCACHIER_USERNAME:REPLACE_WITH_MEMCACHIER_PASSWORD"

If the above request returns an error, ensure that your credentials are configured for API access on your analytics dashboard:

credentials list in the analytics dashboard

Step 3: Set up a deploy hook

After you successfully flush your cache with a cURL request, you can set up a deploy hook with the same set of credentials, like so (substitute your credentials where indicated):

$ heroku addons:create deployhooks:http \
> --url="https://REPLACE_WITH_MEMCACHIER_USERNAME:REPLACE_WITH_MEMCACHIER_PASSWORD@\
> analytics.memcachier.com/api/v1//REPLACE_WITH_MEMCACHIER_CACHE_ID/flush"

And that’s it! Pretty simple. Now, any time you deploy a new commit to Heroku, your cache will automatically flush its old data away, allowing you to run tests on relevant data.

If you ever update replace your MemCachier credentials, you’ll need to manually update your deploy hook as well.

Additional resources

See Deploy Hooks for more information on setting up Heroku deploy hooks.

To learn more about the features of the MemCachier API, see the full documentation.

Keep reading

  • Continuous Delivery

Feedback

Log in to submit feedback.

Review Apps (Old) Heroku ChatOps (Slack Integration)

Information & Support

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

Language Reference

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

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing

Subscribe to our monthly newsletter

Your email address:

  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Heroku Podcasts
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Facebook
  • Instagram
  • Github
  • LinkedIn
  • YouTube
Heroku is acompany

 © Salesforce.com

  • heroku.com
  • Terms of Service
  • Privacy
  • Cookies
  • Cookie Preferences