From b2af8e640cfd57831efe0defb2822434c2b0fdad Mon Sep 17 00:00:00 2001 From: argaen Date: Tue, 14 Feb 2017 00:12:39 +0100 Subject: [PATCH] Use decorator --- examples/cache_example.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/cache_example.py b/examples/cache_example.py index 7c8b2198..df56689f 100644 --- a/examples/cache_example.py +++ b/examples/cache_example.py @@ -21,6 +21,7 @@ from aiocache.serializers import JsonSerializer app = Sanic(__name__) +@app.listener('before_server_start') def init_cache(sanic, loop): aiocache.settings.set_defaults( class_="aiocache.RedisCache", @@ -42,4 +43,4 @@ async def test(request): 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)