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 Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi_redis_vet1ments-0.2.6.tar.gz.
File metadata
- Download URL: fastapi_redis_vet1ments-0.2.6.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b714b306551de786649d3a20290967673fa90fdb2f0439d38eed07aa399132f6
|
|
| MD5 |
f6cbcb4e3fbea4b0c637878625f8e322
|
|
| BLAKE2b-256 |
ae2da37bf79edfc7abf31f5768fbe79b25c8d891e94aff36cfa7ef6b6b84df9d
|
File details
Details for the file fastapi_redis_vet1ments-0.2.6-py3-none-any.whl.
File metadata
- Download URL: fastapi_redis_vet1ments-0.2.6-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbe4417b67f11c20c59a5a86cc9a581512abaacbbda770147b26053f447788ab
|
|
| MD5 |
cd8d8a549efdf10101cafa0852bdedbe
|
|
| BLAKE2b-256 |
51bcb36ded9924d1c1e49a7e7b3daafeb5b83934281c97f249daaec3f16c0e16
|