Automatic Flask cache configuration on Heroku.

Overview

flask-heroku-cacheify

Automatic Flask cache configuration on Heroku.

Thinking Man Sketch

Purpose

Configuring your cache on Heroku can be a time sink. There are lots of different caching addons available on Heroku (Redis, Memcached, etc.), and among those -- lots of competitors.

flask-heroku-cacheify makes your life easy by automatically configuring your Flask application to work with whatever caching addons you've got provisioned on Heroku, allowing you to easily swap out addon providers at will, without any trouble. And, just in case you don't have any suitable Heroku addons available, flask-heroku-cacheify will default back to using local memory for your cache!

Instead of looking through documentation, testing stuff out, etc., flask-heroku-cacheify will just do everything for you :)

Install

To install flask-heroku-cacheify, use pip.

$ pip install flask-heroku-cacheify

NOTE: If you're install flask-heroku-cacheify locally, you'll need to have libmemcached-dev installed on your OS (with SASL support).

Next, modify your requirements.txt file in your home directory, and add the following to the bottom of your file:

Flask-Heroku-Cacheify>=1.3
pylibmc>=1.2.3

The above will ensure that Heroku pulls in the required C header files (in case you decide to use memcached). This step is required.

Pick an Addon

Heroku has lots of available addons you can use for caching. flask-heroku-cacheify currently works with them all! That means no matter which option you choose, your cache will work out of the box, guaranteed!

Below is a list of the addons you can install to get started, you should have at least one of these activated on your Heroku app -- otherwise, your cache will be in 'local memory' only, and won't be very useful.

NOTE My favorite providers are MemCachier (for memcache), and openredis for redis. Both are equally awesome as cache providers. If you're in need of a stable cache provider for large applications, I'd recommend RedisGreen -- they use dedicated EC2 instances (which greatly improves your server power) and have an excellent interface.

Usage

Using flask-heroku-cacheify is super easy! In your app.py (or wherever you define your Flask application), add the following:

from flask_cacheify import init_cacheify

app = Flask(__name__)
cache = init_cacheify(app)

Once you've got your cache global defined, you can use it anywhere in your Flask app:

>>> from app import cache
>>> cache.set('hi', 'there', 30)
>>> cache.get('hi')
'there'

How does this work? In the background, flask-heroku-cacheify is really just automatically configuring the popular Flask-Cache extension! This means, you can basically skip down to this part of their documentation, and begin using all the methods listed there, without worrying about setting up your caches! Neat, right?

For more information and examples of how to use your cache, don't forget to read the Flask-Cache documentation.

Like This?

Like this software? If you really enjoy flask-heroku-cacheify, you can show your appreciation by:

  • Sending me some bitcoin, my address is: 17BE6Q6fRgxJutnn8NsQgeKnACFjzWLbQT
  • Tipping me on gittip.

Either way, thanks! <3

Changelog

1.6.1: 12-20-2017

- Update docs
- Updating code to support latest Flask release

1.6.0: 04-22-2017

- Upgrading to work with latest FLask release (thanks @mattstibbs).

v1.5: 06-20-2015

- Removing MyRedis addon support -- the addon has been shut down.

v1.4: 04-04-2015

- Fixing typos in README.
- Adding Python 3 compatibility.

v1.3: 05-31-2012

- Fixing bug with memcachier support (thanks @eriktaubeneck)!

v1.2: 04-18-2013

- Adding proper documentation.

v1.1: 04-18-2013

- Adding support for MyRedis.
- Adding support for Redis Cloud.
- Adding support for Redis To Go.
- Adding support for openredis.

v1.0: 04-18-2013

- Fixing bug with RedisGreen support.

v0.9: 04-18-2013

- First *real* release! Supports MemCachier and RedisGreen!

v0.8: 04-18-2013

- Pushing eigth release to PyPI (don't use this still!).

v0.7: 04-18-2013

- Pushing seventh release to PyPI (don't use this still!).

v0.6: 04-18-2013

- Pushing sixth release to PyPI (don't use this still!).

v0.5: 04-18-2013

- Pushing fifth release to PyPI (don't use this still!).

v0.4: 04-18-2013

- Pushing fourth release to PyPI (don't use this still!).

v0.3: 04-18-2013

- Pushing third release to PyPI (don't use this still!).

v0.2: 04-18-2013

- Pushing second release to PyPI (don't use this still!).

v0.1: 04-18-2013

- Pushing first release to PyPI (don't use this yet!).

v0.0: 04-14-2013

- Started work >:)
Owner
Randall Degges
I'm just a happy programmer that likes to hack stuff.
Randall Degges
Aircache is an open-source caching and security solution that can be integrated with most decoupled apps that use REST APIs for communicating.

AirCache Aircache is an open-source caching and security solution that can be integrated with most decoupled apps that use REST APIs for communicating

AirCache 2 Dec 22, 2021
A slick ORM cache with automatic granular event-driven invalidation.

Cacheops A slick app that supports automatic or manual queryset caching and automatic granular event-driven invalidation. It uses redis as backend for

Alexander Schepanovski 1.7k Dec 30, 2022
An ORM cache for Django.

Django ORMCache A cache manager mixin that provides some caching of objects for the ORM. Installation / Setup / Usage TODO Testing Run the tests with:

Educreations, Inc 15 Nov 27, 2022
Robust, highly tunable and easy-to-integrate in-memory cache solution written in pure Python, with no dependencies.

Omoide Cache Caching doesn't need to be hard anymore. With just a few lines of code Omoide Cache will instantly bring your Python services to the next

Leo Ertuna 2 Aug 14, 2022
WSGI middleware for sessions and caching

Cache and Session Library About Beaker is a web session and general caching library that includes WSGI middleware for use in web applications. As a ge

Ben Bangert 500 Dec 29, 2022
Persistent, stale-free, local and cross-machine caching for Python functions.

Persistent, stale-free, local and cross-machine caching for Python functions.

Shay Palachy 420 Dec 22, 2022
A Python wrapper around the libmemcached interface from TangentOrg.

pylibmc is a Python client for memcached written in C. See the documentation at sendapatch.se/projects/pylibmc/ for more information. New in version 1

Ludvig Ericson 458 Dec 30, 2022
A caching extension for Flask

A fork of the Flask-cache extension which adds easy cache support to Flask.

Pallets Community 773 Jan 08, 2023
A decorator for caching properties in classes.

cached-property A decorator for caching properties in classes. Why? Makes caching of time or computational expensive properties quick and easy. Becaus

Daniel Roy Greenfeld 658 Dec 01, 2022
RecRoom Library Cache Tool

RecRoom Library Cache Tool A handy tool to deal with the Library cache file. Features Parse Library cache Remove Library cache Parsing The script pars

Jesse 5 Jul 09, 2022
Asynchronous cache manager designed for horizontally scaled web servers.

Introduction Asynchronous cache manager designed for horizontally scaled web applications. NOTE: Currently has implementation only for FastAPI using R

Serghei 23 Dec 01, 2022
No effort, no worry, maximum performance.

Django Cachalot Caches your Django ORM queries and automatically invalidates them. Documentation: http://django-cachalot.readthedocs.io Table of Conte

NoriPyt 976 Dec 28, 2022
Python disk-backed cache (Django-compatible). Faster than Redis and Memcached. Pure-Python.

DiskCache is an Apache2 licensed disk and file backed cache library, written in pure-Python, and compatible with Django.

Grant Jenks 1.7k Jan 05, 2023
Asyncio cache manager for redis, memcached and memory

aiocache Asyncio cache supporting multiple backends (memory, redis and memcached). This library aims for simplicity over specialization. All caches co

aio-libs 764 Jan 02, 2023
Simple caching transport for httpx

httpx-cache is yet another implementation/port is a port of the caching algorithms in httplib2 for use with httpx Transport object.

Ouail 28 Jan 01, 2023
Caching for HTTPX

Caching for HTTPX. Note: Early development / alpha, use at your own risk. This package adds caching functionality to HTTPX Adapted from Eric Larson's

Johannes 51 Dec 04, 2022
johnny cache django caching framework

Johnny Cache is a caching framework for django applications. It works with the django caching abstraction, but was developed specifically with the use

Jason Moiron 304 Nov 07, 2022
CacheControl is a port of the caching algorithms in httplib2 for use with requests session object.

CacheControl CacheControl is a port of the caching algorithms in httplib2 for use with requests session object. It was written because httplib2's bett

Eric Larson 409 Dec 04, 2022
No effort, no worry, maximum performance.

Django Cachalot Caches your Django ORM queries and automatically invalidates them. Documentation: http://django-cachalot.readthedocs.io Table of Conte

NoriPyt 979 Jan 03, 2023
A caching extension for Flask

Flask-Caching Adds easy cache support to Flask. This is a fork of the Flask-Cache extension. Flask-Caching also includes the cache module from werkzeu

Peter Justin 774 Jan 02, 2023