Skip to content

The instructions below are rendered from the canonical example catalogue source. Follow the hosted integration guides in the catalogue to study each application or adapter and its complete program.

Examples

Start with one of the FastAPI applications:

  • Shared workers: real Granian HTTP processes reuse tenant-filtered product documents and one owner stream. The self-check proves the second worker's first read hits without a MongoDB query, verifies invalidation, reads owner diagnostics, and checks graceful shutdown.
  • Compact process-local application: one client and CacheManager per lifespan, cached GETs, direct PATCH responses and diagnostics.
  • Process-local catalogue: tenant filtering, bounded pages and a deployment cache flag. --serve runs independent caches under Uvicorn.

The remaining adapters use process-local caching for MongoDB-backed libraries. Every program checks reuse and invalidation and fails if its expected evidence is absent. Most self-checks use in-process HTTP clients; the shared-worker check opens actual network connections. See manager selection before adapting an integration.

Authorization policies and Celery task state can lag a write until invalidation arrives. Do not use these examples to infer immediate freshness; see consistency limits.

Prerequisites

  • A disposable MongoDB deployment meeting the database requirements. The repository's docker-compose.yaml starts one on localhost:27017, which the examples use by default. To use another deployment, set MONGODB_URI to its connection string.
  • A host meeting the platform requirements, including the additional requirements for shared caching.
  • uv. Each example declares its own dependencies, and uv installs them into a separate, cached environment the first time you run it.

Self-checks reset their dedicated database, for example client_query_cache_example_requests_cache. Use a disposable deployment without valuable data under the client_query_cache_example_ prefix. Web --serve modes leave existing data intact. Keep connection credentials in your normal secret configuration and do not print the URI.

Run the examples

Run each command from the repository checkout. The filenames below link to executable source; the hosted guides explain the integrations.

Example Library or framework Run
fastapi_shared_example.py FastAPI + Granian uv run docs/examples/fastapi_shared_example.py
requests_cache_example.py requests-cache uv run docs/examples/requests_cache_example.py
cachier_example.py cachier (sync) uv run docs/examples/cachier_example.py
cachier_async_example.py cachier (asyncio) uv run docs/examples/cachier_async_example.py
fastapi_catalogue_example.py FastAPI uv run docs/examples/fastapi_catalogue_example.py
fastapi_minimal_example.py FastAPI uv run docs/examples/fastapi_minimal_example.py
celery_example.py Celery uv run docs/examples/celery_example.py
py_abac_example.py py-abac uv run docs/examples/py_abac_example.py
aiohttp_client_cache_example.py aiohttp-client-cache uv run docs/examples/aiohttp_client_cache_example.py
eve_example.py Eve uv run docs/examples/eve_example.py

Run all executable self-checks with just examples; the shared self-check also verifies its --serve launcher.

Hosted integration guides