View the Contents of Redis Directly from the Terminal in Django
Django
2022-12-27 10:15 (3 years ago)

Here is the method to directly view the contents of Django Redis from the Django shell.
./manage.py shell
from django_redis import get_redis_connection
# Create a Redis connection
r = get_redis_connection('default')
# Get a list of keys with a limit
r.scan(count=1000)
# Get a list of keys with a pattern
r.keys('ranking_cache_*')
# The contents are pickled, so they cannot be read as is
r.get('my_cache_key')
# Unpickle to read the contents
import pickle
pickle.loads(r.get('my_cache_key'))
Please rate this article (No signup or login required)
Currently unrated
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.
We look forward to discussing your development needs.