Opened 41 minutes ago

Last modified 40 minutes ago

#37113 assigned Cleanup/optimization

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

  • TIMEOUT
  • OPTIONS['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 TIMEOUT for the caching backend, the cache timeout would be set to 300, the default;
  • If a Django app set a TIMEOUT for the caching backend to 0, the cache timeout would be set to 0, as expected;
  • If a Django app somehow set a TIMEOUT of 'abc', the cache timeout would be set to 300.

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 (1)

comment:1 by jodizzle, 40 minutes ago

Type: UncategorizedCleanup/optimization
Note: See TracTickets for help on using tickets.
Back to Top