Merge pull request #418 from argaen/fix_cache_example

Use decorator for cache example
This commit is contained in:
Eli Uriegas 2017-02-13 17:23:29 -06:00 committed by GitHub
commit 1866e4ef44

View File

@ -21,6 +21,7 @@ from aiocache.serializers import JsonSerializer
app = Sanic(__name__) app = Sanic(__name__)
@app.listener('before_server_start')
def init_cache(sanic, loop): def init_cache(sanic, loop):
aiocache.settings.set_defaults( aiocache.settings.set_defaults(
class_="aiocache.RedisCache", class_="aiocache.RedisCache",
@ -42,4 +43,4 @@ async def test(request):
return json(await expensive_call()) return json(await expensive_call())
app.run(host="0.0.0.0", port=8000, before_start=init_cache) app.run(host="0.0.0.0", port=8000)