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'
# DOGPILE_CACHE_BINARY = True
# ==================== 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.refresh(cached_func, *args) # Refreshing
cache.set(cached_func, value, *args) # Setting custom value
Easy to Install
$ pip install Flask-Dogpile-Cache
Links
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for Flask-Dogpile-Cache-0.1.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2a65828f073a02c20cfc92af318bd3fe4e082cb1ed5c831612976c7c479641f |
|
MD5 | 369c27d8b6fd2648ee1ebf6f55f8a436 |
|
BLAKE2b-256 | 800ec69156ba5641cbc79aee529f5135be739001b44f401857a90a8c413df346 |