Make key used in CacheBackend externally readable
Flauschbaellchen opened this issue · 1 comments
Flauschbaellchen commented
On a point in our application part of the cache needs to be invalidated.
The algorithm then needs to know which key/value entry django-health-check
has inserted into the cache for either ignoring the entry alltogether, or to handle it differently than the other ones.
Currently, the key is hidden within CacheBackend
as a string which is not externally accessible.
The application would need to write something like this:
for key in cache.keys("*"):
if key == "djangohealtcheck_test":
continue
# do some magic
Using a static class variable, one could write:
for key in cache.keys("*"):
if key == CacheBackend.HEALTH_CHECK_KEY:
continue
# do some magic
It won't be faster, but it would not crash or have unknown side-effects if the key changes.
I've created PR #336.
I'd appreciate any comments about this change.
Flauschbaellchen commented
PR has been merged.