You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(config): add cache_config field to SQLAlchemy configs
Closeslitestar-org#730.
The dogpile.cache integration (litestar-org#636) added the `advanced_alchemy.cache`
package, listeners, and repository wiring, but never extended
`SQLAlchemyAsyncConfig` / `SQLAlchemySyncConfig` with the `cache_config`
kwarg that the caching guide promotes. Every example in
`docs/usage/caching.rst` raised `TypeError` because the field did not
exist.
This adds `cache_config: Optional[CacheConfig]` and
`cache_manager: Optional[CacheManager]` to `GenericSQLAlchemyConfig`.
`__post_init__` builds a `CacheManager` from `cache_config` when one is
not supplied explicitly, then publishes it to sessions via
`session_config.info["cache_manager"]` so repositories pick it up
through the existing `session.info.get("cache_manager")` path.
`session_config` and its `info` dict are now shallow-copied during
`__post_init__` so two configs constructed with the same
`session_config` instance no longer alias each other's cache_manager or
`file_object_raise_on_error` flag. `__hash__` also includes
`id(cache_manager)` so configs that differ only by cache region remain
distinguishable in the class-level registries.
Imports of `CacheConfig` / `CacheManager` are lazy: only typed under
TYPE_CHECKING at module load, and only imported at runtime inside
`__post_init__` when `cache_config` is set, so dogpile.cache probing
is still avoided for configs that don't opt in.
0 commit comments