Welcome to Radish’s documentation!

radish is a pythonic Redis interface with support for asyncio (PEP 3156) and type hints (PEP 484).

Example Usage

radish uses Pydantic to declare schemas for resources stored in Redis, and handles serialization, validation and namespacing for you:

from datetime import datetime
from typing import List, Tuple

from pydantic import BaseModel
import radish


class Customer(BaseModel):
    id: int
    name: str


class Order(BaseModel):
    id: int
    item_id: int
    timestamp: datetime
    customer: Customer


class Radish(radish.Interface):
    customers = radish.Resource(Customer, key="id", db=0)
    orders = radish.Resource(Order, key="id", db=1)


async def get_customer_orders(customer_id: int) -> Tuple[Customer, List[Order]]:
    async with Radish(address="redis://redis") as cache:
        customer = await cache.customers.get(customer_id)
        orders = [
            order async for order in cache.orders.filter(customer=customer)
        ]
        return customer, orders


async def get_all_customers() -> List[Customer]:
    async with Radish(address="redis://redis") as cache:
        return [customer async for customer in cache.customers]

Requirements

This package is currently tested for Python 3.7. It uses Pydantic and aioredis.

Indices and tables