@@ -106,56 +106,50 @@ There are several ways to specify a database number:
106106- If using the ``redis:// `` scheme, the path argument of the URL, e.g.
107107 ``redis://localhost/0 ``
108108
109- When using `Redis' ACLs <https://redis.io/topics/acl >`_, you will need to add the
110- username to the URL (and provide the password with the Cache ``OPTIONS ``).
109+ When using `Redis' ACLs <https://redis.io/topics/acl >`_, you will need to add
110+ the username and the password in the connection string or in ``OPTIONS `` with
111+ the keys ``USERNAME `` and ``PASSWORD ``. *NOTE: Values in the connection string
112+ have precedence! *
113+
111114The login for the user ``django `` would look like this:
112115
113116.. code-block :: python
114117
115118 CACHES = {
116119 " default" : {
117120 " BACKEND" : " django_redis.cache.RedisCache" ,
118- " LOCATION" : " redis://django@localhost:6379/0" ,
119- " OPTIONS" : {
120- " CLIENT_CLASS" : " django_redis.client.DefaultClient" ,
121- " PASSWORD" : " mysecret"
122- }
121+ " LOCATION" : " redis://django:mysecret@localhost:6379/0" ,
123122 }
124123 }
125124
126- An alternative would be write both username and password into the URL :
125+ Instead you may specify both of these values in `` OPTIONS `` :
127126
128127.. code-block :: python
129128
130129 CACHES = {
131130 " default" : {
132131 " BACKEND" : " django_redis.cache.RedisCache" ,
133- " LOCATION" : " redis://django:mysecret@ localhost:6379/0" ,
132+ " LOCATION" : " redis://localhost:6379/0" ,
134133 " OPTIONS" : {
135- " CLIENT_CLASS" : " django_redis.client.DefaultClient" ,
134+ " USERNAME" : " django" ,
135+ " PASSWORD" : " mysecret" ,
136136 }
137137 }
138138 }
139139
140- In some circumstances the password you should use to connect Redis
141- is not URL-safe, in this case you can escape it or just use the
142- convenience option in ``OPTIONS `` dict:
140+ And, finally you may mix the two as follows (be sure not to include a password,
141+ even if blank in the connection string):
143142
144143.. code-block :: python
145144
146145 CACHES = {
147146 " default" : {
148147 " BACKEND" : " django_redis.cache.RedisCache" ,
149- " LOCATION" : " redis://127.0.0.1:6379/1" ,
150- " OPTIONS" : {
151- " CLIENT_CLASS" : " django_redis.client.DefaultClient" ,
152- " PASSWORD" : " mysecret"
153- }
148+ " LOCATION" : " redis://django@localhost:6379/0" ,
149+ " OPTIONS" : {" PASSWORD" : " mysecret" }
154150 }
155151 }
156152
157- Take care, that this option does not overwrites the password in the uri, so if
158- you have set the password in the uri, this settings will be ignored.
159153
160154 Configure as session backend
161155~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -708,8 +702,11 @@ In order to enable this functionality you should add the following:
708702 # Sentinels which are passed directly to redis Sentinel.
709703 " SENTINELS" : SENTINELS ,
710704
711- # kwargs for redis Sentinel (optional).
712- " SENTINEL_KWARGS" : {},
705+ # kwargs for redis Sentinel (optional). Example with auth on sentinels
706+ " SENTINEL_KWARGS" : {
707+ " username" : " sentinel-user" ,
708+ " password" : " sentinel-pass" ,
709+ },
713710
714711 # You can still override the connection pool (optional).
715712 " CONNECTION_POOL_CLASS" : " redis.sentinel.SentinelConnectionPool" ,
0 commit comments