You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a use case where I need to dynamically change my cache to point to a different Redis endpoint depending on how my Django code is executed. My Django code sits in a lambda, and can end up being applied to different environments, which use different caching endpoints.
Unfortunately, the way this package is implemented, the "cache" variable (current cache to use) is a global variable at the module scope of the invalidation.py module and cannot be easily overridden. I thought about subclassing, but that's no good unless I create my own version of everything in the invalidation.py module and then subclass everything that imports it.
from caching import config
try:
import redis as redislib
except ImportError:
redislib = None
# Look for an own cache first before falling back to the default cache
try:
cache = caches["cache_machine"]
except (InvalidCacheBackendError, ValueError):
cache = default_cache
log = logging.getLogger("caching.invalidation")
It seems like it would be a simple change on your end to create a class with some class-vars and class methods for setting/getting the current cache and have all the other classes reference that. Then, before I start instantiating the other classes, I could just set the current cache in that one class, and everything would pick it up.
My only option at this point is to copy this entire package into my codebase and modify it as I suggested or to fork it with the proposed changes. I'd rather give you all the chance to make the change, rather than end up with lots of forks lying around (although looks like you already have 162 of them...)
If you can respond quickly just to indicate if this is something you'd be willing to consider, or if you're willing to let me make the change (I'm happy to), and then create a PR for your review, that would be super helpful as I need this functionality pretty soon.
Thanks!
The text was updated successfully, but these errors were encountered:
I have a use case where I need to dynamically change my cache to point to a different Redis endpoint depending on how my Django code is executed. My Django code sits in a lambda, and can end up being applied to different environments, which use different caching endpoints.
Unfortunately, the way this package is implemented, the "cache" variable (current cache to use) is a global variable at the module scope of the
invalidation.py
module and cannot be easily overridden. I thought about subclassing, but that's no good unless I create my own version of everything in theinvalidation.py
module and then subclass everything that imports it.It seems like it would be a simple change on your end to create a class with some class-vars and class methods for setting/getting the current cache and have all the other classes reference that. Then, before I start instantiating the other classes, I could just set the current cache in that one class, and everything would pick it up.
My only option at this point is to copy this entire package into my codebase and modify it as I suggested or to fork it with the proposed changes. I'd rather give you all the chance to make the change, rather than end up with lots of forks lying around (although looks like you already have 162 of them...)
If you can respond quickly just to indicate if this is something you'd be willing to consider, or if you're willing to let me make the change (I'm happy to), and then create a PR for your review, that would be super helpful as I need this functionality pretty soon.
Thanks!
The text was updated successfully, but these errors were encountered: