Updating documentation to use redis.asyncio (#447)
* removing aioredis from documentation * fix: proper python 3.11 support (#446) * fix: propper python 3.11 support * fix tox config * wider python 3.x support * Update ci.yml Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com> * Add poetry.lock to .gitignore (#457) * Add poetry.lock to .gitignore * remove poetry.lock * PR comments readme update Co-authored-by: Yaraslau Zhylko <YaraslauZhylko@gmail.com> Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com>
This commit is contained in:
parent
1aa619e418
commit
6955225c08
6 changed files with 22 additions and 26 deletions
|
|
@ -36,7 +36,7 @@ Let's look at an example FastAPI app that uses Redis OM.
|
|||
import datetime
|
||||
from typing import Optional
|
||||
|
||||
import aioredis
|
||||
import redis
|
||||
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from starlette.requests import Request
|
||||
|
|
@ -94,7 +94,7 @@ async def get_customer(pk: str, request: Request, response: Response):
|
|||
|
||||
@app.on_event("startup")
|
||||
async def startup():
|
||||
r = aioredis.from_url(REDIS_CACHE_URL, encoding="utf8",
|
||||
r = redis.asyncio.from_url(REDIS_CACHE_URL, encoding="utf8",
|
||||
decode_responses=True)
|
||||
FastAPICache.init(RedisBackend(r), prefix="fastapi-cache")
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ Here is the previous FastAPI app, but using asyncio-compatible Redis OM code:
|
|||
import datetime
|
||||
from typing import Optional
|
||||
|
||||
import aioredis
|
||||
import redis
|
||||
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from starlette.requests import Request
|
||||
|
|
@ -206,7 +206,7 @@ async def get_customer(pk: str, request: Request, response: Response):
|
|||
|
||||
@app.on_event("startup")
|
||||
async def startup():
|
||||
r = aioredis.from_url(REDIS_CACHE_URL, encoding="utf8",
|
||||
r = redis.asyncio.from_url(REDIS_CACHE_URL, encoding="utf8",
|
||||
decode_responses=True)
|
||||
FastAPICache.init(RedisBackend(r), prefix="fastapi-cache")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue