docs/examples/stores/namespacing.py
raw| 1 | from litestar import Litestar |
| 2 | from litestar.stores.redis import RedisStore |
| 3 | |
| 4 | root_store = RedisStore.with_client() |
| 5 | cache_store = root_store.with_namespace("cache") |
| 6 | session_store = root_store.with_namespace("sessions") |
| 7 | |
| 8 | |
| 9 | async def before_shutdown() -> None: |
| 10 | await cache_store.delete_all() |
| 11 | |
| 12 | |
| 13 | app = Litestar(before_shutdown=[before_shutdown]) |