Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also support django_prpmetheus wrapped caches #167

Closed
wants to merge 1 commit into from

Conversation

Natureshadow
Copy link
Contributor

Description

Add the cache backends wrapped by django_prometheus as supported backends.

Rationale

cachalot already explicitly supports django_prometheus' wrappers for database backends. djanfo_prometheus does the same wrapping for cache backends, so they should be supported as well.

@coveralls
Copy link

coveralls commented Nov 13, 2020

Pull Request Test Coverage Report for Build 672

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 98.956%

Totals Coverage Status
Change from base Build 670: 0.0%
Covered Lines: 3223
Relevant Lines: 3257

💛 - Coveralls

7 similar comments
@coveralls
Copy link

Pull Request Test Coverage Report for Build 672

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 98.956%

Totals Coverage Status
Change from base Build 670: 0.0%
Covered Lines: 3223
Relevant Lines: 3257

💛 - Coveralls

@coveralls
Copy link

Pull Request Test Coverage Report for Build 672

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 98.956%

Totals Coverage Status
Change from base Build 670: 0.0%
Covered Lines: 3223
Relevant Lines: 3257

💛 - Coveralls

@coveralls
Copy link

Pull Request Test Coverage Report for Build 672

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 98.956%

Totals Coverage Status
Change from base Build 670: 0.0%
Covered Lines: 3223
Relevant Lines: 3257

💛 - Coveralls

@coveralls
Copy link

Pull Request Test Coverage Report for Build 672

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 98.956%

Totals Coverage Status
Change from base Build 670: 0.0%
Covered Lines: 3223
Relevant Lines: 3257

💛 - Coveralls

@coveralls
Copy link

Pull Request Test Coverage Report for Build 672

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 98.956%

Totals Coverage Status
Change from base Build 670: 0.0%
Covered Lines: 3223
Relevant Lines: 3257

💛 - Coveralls

@coveralls
Copy link

Pull Request Test Coverage Report for Build 672

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 98.956%

Totals Coverage Status
Change from base Build 670: 0.0%
Covered Lines: 3223
Relevant Lines: 3257

💛 - Coveralls

@coveralls
Copy link

Pull Request Test Coverage Report for Build 672

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 98.956%

Totals Coverage Status
Change from base Build 670: 0.0%
Covered Lines: 3223
Relevant Lines: 3257

💛 - Coveralls

@Andrew-Chen-Wang
Copy link
Collaborator

@Natureshadow I'm planning on removing those databases in the next release. You can add support yourself by adding in your settings: https://django-cachalot.readthedocs.io/en/latest/quickstart.html#cachalot-databases

@Natureshadow
Copy link
Contributor Author

Natureshadow commented Nov 14, 2020 via email

@Andrew-Chen-Wang
Copy link
Collaborator

Most important thing:

@register(Tags.caches, Tags.compatibility)
def check_cache_compatibility(app_configs, **kwargs):
cache = settings.CACHES[cachalot_settings.CACHALOT_CACHE]
cache_backend = cache['BACKEND']
if cache_backend not in SUPPORTED_CACHE_BACKENDS:
return [Warning(
'Cache backend %r is not supported by django-cachalot.'
% cache_backend,
hint='Switch to a supported cache backend '
'like Redis or Memcached.',
id='cachalot.W001')]
return []

So even if your cache is configured as:

CACHES = {

"default": {"BACKEND": "whatever"}
}

Django only raises a warning, and you can mute the warning. Unlike the databases setting, this one will not raise an error, only a warning which can be muted in your settings.

We use Django's regular django.core.cache.cache API. So if your app also uses something like:

from django.core.cache import cache

cache.get("key")

and the regular basic ones found in BaseCache, then cachalot should support it. I believe, IIRC, we only use get or set.

@Natureshadow
Copy link
Contributor Author

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants