django-constance icon indicating copy to clipboard operation
django-constance copied to clipboard

Advice needed: Wrap Redis backend with in-memory backend function?

Open gabriels1234 opened this issue 2 years ago • 1 comments

Describe the problem

Using the Redis Backend, and calling config.VARIABLE repeatedly for the many variables slows down the performance ((tested)).

I ask, from a theoretic standpoint:

Is there something to gain from wrapping the calls to constance values with an in-memory cache (e.g get_constance_value(value, cache_ttl)) that will get the value from Redis the first time, and keep it in-memory (e.g. for 60 seconds)?

gabriels1234 avatar Sep 29 '22 20:09 gabriels1234

You can try to use CachingRedisBackend via CONSTANCE_BACKEND = 'constance.backends.redisd.CachingRedisBackend'. See details in docs.

horpto avatar Sep 29 '22 20:09 horpto