revsys / django-health-check

a pluggable app that runs a full check on the deployment, using a number of plugins to check e.g. database, queue server, celery processes, etc.

Home Page:https://readthedocs.org/projects/django-health-check/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make key used in CacheBackend externally readable

Flauschbaellchen opened this issue · comments

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.

commented

PR has been merged.