redis 쉽게
Project description
FASTAPI REDIS
USAGE
from fastapi_redis import (
FastAPIRedis,
FastAPIAsyncRedis
)
from fastapi_redis.types import (
RedisClient,
AsyncRedisClient,
FastAPIAsyncRedis,
FastAPIRedis
)
from fastapi import (
FastAPI,
Depends
)
app = FastAPI()
redis = FastAPIRedis(
host="127.0.0.1",
port="6379"
)
async_redis = FastAPIAsyncRedis(
host="127.0.0.1",
port="6379"
)
# In Depends
@app.get("/")
def get(
rd: RedisClient = Depends(redis.get_connection)
):
rd.get("test")
@app.get('/')
async def get(
rd: AsyncRedisClient = Depends(async_redis.get_connection)
):
await rd.get("test")
# Outside of Depends
@app.get("/")
def get():
conn: RedisClient
with redis.get_connection_() as conn:
conn.get("test")
@app.get("/")
async def get():
conn: AsyncRedisClient
async with async_redis.get_connection_() as conn:
await conn.get("test")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for fastapi_redis_vet1ments-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44941d8457f935f3dd8d3eb49e5c90ad5944b81c9bd64f2947c32bf71c5bc5d3 |
|
MD5 | 5a610dab8af13917ca060ffe0280c683 |
|
BLAKE2b-256 | cc554fe5d91b2e249d2b9a8a5d12a70943dd68c3de109573b8ce8b0f093413b2 |