Caching example (#150)
* Caching example using aiocache * Caching example using aiocache * Added aiocache to requirements * Fixed example with newest aiocache
This commit is contained in:
parent
49d004736a
commit
edb25f799d
|
@ -15,11 +15,14 @@ import aiocache
|
||||||
from sanic import Sanic
|
from sanic import Sanic
|
||||||
from sanic.response import json
|
from sanic.response import json
|
||||||
from sanic.log import log
|
from sanic.log import log
|
||||||
from aiocache import RedisCache, cached
|
from aiocache import cached
|
||||||
from aiocache.serializers import JsonSerializer
|
from aiocache.serializers import JsonSerializer
|
||||||
|
|
||||||
app = Sanic(__name__)
|
app = Sanic(__name__)
|
||||||
aiocache.set_defaults(cache=RedisCache)
|
|
||||||
|
aiocache.settings.set_defaults(
|
||||||
|
cache="aiocache.RedisCache"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@cached(key="my_custom_key", serializer=JsonSerializer())
|
@cached(key="my_custom_key", serializer=JsonSerializer())
|
||||||
|
|
Loading…
Reference in New Issue
Block a user