django- cache django-redis

https://django-redis-chs.readthedocs.io/zh_CN/latest/

django-redis easiest way to install is to use pip:

pip install django-redis==4.7.0

 cache backend using the configuration settings.py


"django.contrib.sessions.backends.cache"
SESSION_CACHE_ALIAS = "default"

Redis database link, use the native client

In some cases you need to get into a native application Redis client to use the advanced characteristics of some django cache interface is not exposed. In order to avoid storing another new native connection generated set, django-redis provides a method  get_redis_connection(alias) to make you obtaining reusable connection string.

>>> from django_redis import get_redis_connection
>>> con = get_redis_connection("default")
>>> con
<redis.client.StrictRedis object at 0x2dc4510>

 

Guess you like

Origin www.cnblogs.com/yifengs/p/11614854.html
Recommended