Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Adds dogpile.cache support to your Flask application

Project Description

Easy to Use

# ==================== config.py ====================

DOGPILE_CACHE_URLS = ["127.0.0.1:11211"]
DOGPILE_CACHE_REGIONS = [
    ('hour', 3600),
    ('day', 3600 * 24),
    ('month', 3600 * 24 * 31),
]
# Default settings:
# DOGPILE_CACHE_BACKEND = 'dogpile.cache.memcached'


# ==================== app.py ====================

import config
from flask import Flask
from flask.ext.dogpile_cache import DogpileCache

app = Flask(__name__)
app.config.from_object(config)

cache = DogpileCache()
cache.init_app(app)
# Alternative way: cache = DogpileCache(app)

@cache.region('hour')
def cached_func(*args):
    print "Heavy computation here", args
    return args

value = cached_func()

cache.invalidate(cached_func, *args)  # Invalidating cache for cached_func
cache.refresh(cached_func, *args)     # Refreshing cache for cached_func
cache.set(cached_func, value, *args)  # Setting custom value for cached_func
cache.invalidate_region('hour')       # Invalidate cache for all funcs
                                      # decorated with @cache.region('hour')
cache.invalidate_all_regions()        # Invalidate cache for all funcs
                                      # decorated with @cache.region

Easy to Install

$ pip install Flask-Dogpile-Cache
Release History

Release History

This version
History Node

0.2

History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

History Node

0.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
Flask-Dogpile-Cache-0.2.tar.gz (6.4 kB) Copy SHA256 Checksum SHA256 Source Nov 26, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting