Skip to content

agile4you/bottle-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

https://travis-ci.org/agile4you/bottle-cache.svg?branch=master https://coveralls.io/repos/agile4you/bottle-cache/badge.svg?branch=master&service=github

bottle_cache: Cache plugin for bottle.py applications

Example Usage

import bottle
from bottle_cache.plugin import (cache_for, CachePlugin)

cache = CachePlugin('url_cache', 'redis', host='localhost', port=6379, db=1)

app = bottle.Bottle()
app.install(cache)


# You can either cache the result of a web handler
# for a ttl (json, or html)

@app.get('/')
@cache_for(20, cache_key_func='full_path')
def api_handler():
    print('Cache miss')
    return {'a': 1, 'b': 3}


# Or you can inject the cache instance directly
# to handler for more flexibility and custom implementations

@app.get('/cache')
def cache_handler(url_cache):
    return {"cache_info": str(url_cache)}


bottle.run(app=app, port=8080, reloader=True)

About

Cache Plugins for bottle.py applications

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages