#37113 closed Cleanup/optimization (needsnewfeatureprocess)
Don't let cache backends swallow explicit errors in cache arguments
| Reported by: | jodizzle | Owned by: | jodizzle |
|---|---|---|---|
| Component: | Core (Cache system) | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | jodizzle | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
The following cache arguments
TIMEOUTOPTIONS['MAX_ENTRIES']OPTIONS['CULL_FREQUENCY']
are integer values that are handled by `BaseCache` such that non-integer values are ignored and fallback to the default. For example:
- If a Django app didn't set a
TIMEOUTfor the caching backend, the cache timeout would be set to300, the default; - If a Django app set a
TIMEOUTfor the caching backend to0, the cache timeout would be set to0, as expected; - If a Django app somehow set a
TIMEOUTof'abc', the cache timeout would be set to300.
My feeling is that the third behavior is wrong. If any of these settings can't be parsed by Django as an integer, Django should throw an error to make it clear to the user that the app is improperly configured.
I'll also note:
- This behavior does not seem to be documented. The cache arguments section of the documentation mentions the default values, and makes it fairly clear that the settings are for integers, but it doesn't mention that inappropriate values are forced to the defaults.
- This behavior does not seem to be tested in the test suite. If the error swallowing logic is removed, the test suite still passes.
Change History (3)
comment:1 by , 3 weeks ago
| Type: | Uncategorized → Cleanup/optimization |
|---|
comment:2 by , 3 weeks ago
| Resolution: | → needsnewfeatureprocess |
|---|---|
| Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
I think we need to confirm that folks are experiencing this as an issue to validate adding a new system check to validate this here is worth it
Can you discuss on the new features board and see if the community is in favor of this change? https://github.com/django/new-features