Skip to main content

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")

Release files for fastapi-redis-vet1ments 0.2.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastapi-redis-vet1ments 0.2.6
File Size Uploaded
fastapi_redis_vet1ments-0.2.6.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fastapi-redis-vet1ments 0.2.6
File Interpreter ABI Platform
fastapi_redis_vet1ments-0.2.6-py3-none-any.whl Python 3 none any Details

Total release size: 10.0 kB

Release files / fastapi_redis_vet1ments-0.2.6.tar.gz

Download URL fastapi_redis_vet1ments-0.2.6.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b714b306551de786649d3a20290967673fa90fdb2f0439d38eed07aa399132f6
BLAKE2b-256 checksum
How to use checksums
ae2da37bf79edfc7abf31f5768fbe79b25c8d891e94aff36cfa7ef6b6b84df9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / fastapi_redis_vet1ments-0.2.6-py3-none-any.whl

Download URL fastapi_redis_vet1ments-0.2.6-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fbe4417b67f11c20c59a5a86cc9a581512abaacbbda770147b26053f447788ab
BLAKE2b-256 checksum
How to use checksums
51bcb36ded9924d1c1e49a7e7b3daafeb5b83934281c97f249daaec3f16c0e16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.2.6 This release

2 release files

0.2.5

2 release files

0.2.1

1 release file

0.2.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page