MCPcopy Index your code
hub / github.com/long2ice/fastapi-cache / lifespan

Function lifespan

examples/redis/main.py:24–28  ·  view source on GitHub ↗
(_: FastAPI)

Source from the content-addressed store, hash-verified

22
23@asynccontextmanager
24async def lifespan(_: FastAPI) -> AsyncIterator[None]:
25 pool = ConnectionPool.from_url(url="redis://redis")
26 r = redis.Redis(connection_pool=pool)
27 FastAPICache.init(RedisBackend(r), prefix="fastapi-cache")
28 yield
29
30
31app = FastAPI(lifespan=lifespan)

Callers

nothing calls this directly

Calls 2

RedisBackendClass · 0.90
initMethod · 0.45

Tested by

no test coverage detected