0

I am using the following in my Django project:

django-redis-cache==2.1.1
redis==3.5.5
Django==2.2.13
Python 3.7.5

In my settings.py I specified the following cache:

CACHES = {
    "default": {
        "BACKEND": "redis_cache.RedisCache",
        "LOCATION": "xxxxx.cloud.redislabs.com:10790",
        "OPTIONS": {
            "DB": 0,
            "PASSWORD": "xxxxx",
            "CONNECTION_POOL_CLASS": "redis.BlockingConnectionPool",
            "CONNECTION_POOL_CLASS_KWARGS": {"max_connections": 20, "timeout": 3,},
        },
        "KEY_PREFIX": "django_backend_2",
    }
}

Nowhere in any of my django apps am I actually using this redis cache, and I also have never_cache enabled in all my apps. The session_engine is set to use files:

SESSION_ENGINE = 'django.contrib.sessions.backends.file'

But, when I check the keys in my redis, I see random keys get created and removed all the time:

(My prefix was django_backend then I changed it to django_backend_2 that is why you will see some prefixes as django_backend and some as django_backend_2.)

The values in these keys are also just integers.

b'django_backend_:1:rl:5409e278e64a68dc9647a76efdb1ebc6'
b'3'
b'django_backend_2:1:rl:7782bafff6e59026ab9128fcc171e742'
b'1'
b'django_backend_2:1:rl:8e35c29a5fcaea902eecb25b1eee5819'
b'4'
b'django_backend_:1:rl:8e35c29a5fcaea902eecb25b1eee5819'
b'2'
b'django_backend_2:1:rl:3d985fa28195dd6b27e8daa27d7a5b9c'
b'3'
b'django_backend_2:1:rl:97dbbf58e1f6191742336f77d6a0ee3f'
b'4'
b'django_backend_2:1:rl:d910a2d3f55adfcf17800e1be0a29ccc'
b'1'
b'django_backend_2:1:rl:a441f5cb14e949fd09ba967eb46df4a3'
b'2'
b'django_backend_2:1:rl:bd0ea6a16e224fd4dc7d00ee4923d502'
b'1'
b'django_backend_2:1:rl:db9c27edb5144791755378ed13691895'
b'1'
b'django_backend_2:1:rl:ddd02c9082d5203419fcd111f5d99b4a'
b'2'
b'django_backend_:1:rl:645c9769365940fa54818e0a99b5f7c6'
b'1'
b'django_backend_2:1:rl:9451df4e327529d0a9280c0cb3a76bbf'
b'1'
b'django_backend_2:1:rl:5409e278e64a68dc9647a76efdb1ebc6'
b'6'
b'django_backend_2:1:rl:b00a484f84287df2318b18ac6c3831aa'
b'2'
b'django_backend_2:1:rl:ee4f17e6c6fa1004811335ba199b5514'
b'1'
b'django_backend_:1:rl:ddd02c9082d5203419fcd111f5d99b4a'
b'1'
b'django_backend_2:1:rl:ec0959c9a1fb66a639fa4335b674cd1b'
b'1'
b'django_backend_:1:rl:3d985fa28195dd6b27e8daa27d7a5b9c'
b'1'
b'django_backend_2:1:rl:645c9769365940fa54818e0a99b5f7c6'
b'4'
b'django_backend_2:1:rl:13c420622b99b075ac456310ce353ef9'
b'1'
b'django_backend_2:1:rl:527977de6f4097bc2e9479f1d395e94f'
b'1'
b'django_backend_2:1:rl:3200f5f1ed135d5875a48cb2abc16a1a'
b'1'
b'django_backend_2:1:rl:9a069775ac907715dd5d35e32d622070'
b'1'

Why is this happening as the number of keys just seem to keep on growing and growing.

Thank you

Vishal Singh
  • 6,014
  • 2
  • 17
  • 33
  • So my default cache was set to Redis. When I changed my default cache to "django.core.cache.backends.filebased.FileBasedCache" I could see *.djcache files being created. I still dont know what the djcache files are because I dont use sessions or middleware caching. No idea why these djcache files are still being created. At least it is not hammering my redis anymore. – necrolingus Jun 24 '20 at 09:36
  • are you able to access your redis-cli? – Vishal Singh Jun 24 '20 at 13:29
  • Hi Vishal, yes I can. – necrolingus Jun 25 '20 at 06:50
  • after opening redis-cli, type in `MONITOR` to see in real-time when keys are being created or updated. – Vishal Singh Jun 25 '20 at 08:16
  • the keys are created whenever a new request is made to Django. I subsequently changed my "default" caches key to files, and now the djcache files are created on disk which is OK for now. But my problem is, I dont know what setting to specify in settings.py so that I can control where these djcache files should go to. The thing is, I already changed session_cache and middleware_cache settings, but the djcache files is not one of them, it must be another setting. – necrolingus Jun 25 '20 at 11:28

0 Answers0