Repository navigation
Make CacheConfig() the Client cache default and None the off switch - #3164
Merged
Merged
Conversation
The cache field was a three-state CacheConfig | Literal[False] | None where None meant "use the default config" and False meant "disabled". Since CacheConfig is a frozen dataclass and the store is instantiated per client, a plain CacheConfig() default is inert to share, so the sentinel bought nothing. Default to CacheConfig() and let None disable caching.
maxisbey
marked this pull request as ready for review
July 25, 2026 16:39
Contributor
📚 Documentation preview
|
Client.cachewas typedCacheConfig | Literal[False] | None, a three-state sentinel whereNonemeant "use the default config" andFalsemeant "disabled". This collapses it toCacheConfig | Nonewithfield(default_factory=CacheConfig): the defaultCacheConfig()is cache-on, andNoneturns caching off.Motivation and Context
The
None-as-auto sentinel exists to avoid sharing a default instance, but that concern isn't real here:CacheConfigis a frozen dataclass andstore=Nonealready means "build a freshInMemoryResponseCacheStoreper client", so the config carries no per-client state. With that gone,Nonecan mean what it means everywhere else (no cache), and theif self.cache is not False: config = self.cache if self.cache is not None else CacheConfig()dance in__post_init__collapses toif self.cache is not None.How Has This Been Tested?
Updated the existing caching, subscription and docs tests for the new spelling (
cache=Nonein place ofcache=False); exercised default /CacheConfig()/Noneend-to-end against an in-process server with attlMshint.Breaking Changes
cache=Falseis nowcache=None. The response cache is new onmain(SEP-2549, not onv1.x), so there's no released API to migrate.Types of changes
Checklist