﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33060	Add a helper function to make and validate cache keys.	Nick Pope	Nick Pope	"Following from [https://github.com/django/django/pull/14437#discussion_r696351175 this thread] the following pattern is repeated a lot in the cache backends:

{{{#!python
        key = self.make_key(key, version=version)
        self.validate_key(key)
}}}

We can define a helper function on the base cache backend that can be used to avoid repetitiveness and help ensure that we consistently call `.validate_key()` after `.make_key()`:

{{{#!python
    def make_and_validate_key(self, key, version=None):
        key = self.make_key(key, version=version)
        self.validate_key(key)
        return key
}}}

An alternative proposal is to have `.make_key()` learn a `validate` flag, but we'd probably need to have it as `False` by default for backward compatibility and we'd may still have issues if users have overridden `.make_key()`. So it would require documentation changes, release notes, and a deprecation period."	Cleanup/optimization	closed	Core (Cache system)	dev	Normal	fixed			Ready for checkin	1	0	0	0	0	0
