Skip to main content

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

fastapi_redis_vet1ments-0.2.6.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

fastapi_redis_vet1ments-0.2.6-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_redis_vet1ments-0.2.6.tar.gz.

File metadata

File hashes

Hashes for fastapi_redis_vet1ments-0.2.6.tar.gz
Algorithm Hash digest
SHA256 b714b306551de786649d3a20290967673fa90fdb2f0439d38eed07aa399132f6
MD5 f6cbcb4e3fbea4b0c637878625f8e322
BLAKE2b-256 ae2da37bf79edfc7abf31f5768fbe79b25c8d891e94aff36cfa7ef6b6b84df9d

See more details on using hashes here.

File details

Details for the file fastapi_redis_vet1ments-0.2.6-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_redis_vet1ments-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 fbe4417b67f11c20c59a5a86cc9a581512abaacbbda770147b26053f447788ab
MD5 cd8d8a549efdf10101cafa0852bdedbe
BLAKE2b-256 51bcb36ded9924d1c1e49a7e7b3daafeb5b83934281c97f249daaec3f16c0e16

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page