diff -Nru django-redis-4.9.0/AUTHORS.rst django-redis-4.10.0/AUTHORS.rst --- django-redis-4.9.0/AUTHORS.rst 2015-02-20 12:53:31.000000000 +0000 +++ django-redis-4.10.0/AUTHORS.rst 2018-11-19 08:48:56.000000000 +0000 @@ -12,3 +12,4 @@ Todd Boland / boland David Zderic / dzderic Kirill Zaitsev / teferi +Jon Dufresne diff -Nru django-redis-4.9.0/CHANGES.txt django-redis-4.10.0/CHANGES.txt --- django-redis-4.9.0/CHANGES.txt 2018-03-01 10:29:45.000000000 +0000 +++ django-redis-4.10.0/CHANGES.txt 2018-11-19 08:55:58.000000000 +0000 @@ -1,6 +1,25 @@ Changelog ========= +Version 4.10.0 +-------------- + +Date: 2018-10-19 + +- Add support and testing for Django 2.1 and Python 3.7. No actual code changes + were required. +- Add support for redis-py 3.0. +- Add touch command. + + +Version 4.9.1 +------------- + +Date: 2018-10-19 + +- Pin redis version to 2.10.6 + + Version 4.9.0 ------------- diff -Nru django-redis-4.9.0/debian/changelog django-redis-4.10.0/debian/changelog --- django-redis-4.9.0/debian/changelog 2018-03-03 18:40:09.000000000 +0000 +++ django-redis-4.10.0/debian/changelog 2018-11-28 19:39:31.000000000 +0000 @@ -1,3 +1,10 @@ +django-redis (4.10.0-1) unstable; urgency=low + + * New upstream release. + * Bump Standards-Version to 4.2.1. + + -- Michael Fladischer Wed, 28 Nov 2018 20:39:31 +0100 + django-redis (4.9.0-1) unstable; urgency=low [ Scott Kitterman ] diff -Nru django-redis-4.9.0/debian/control django-redis-4.10.0/debian/control --- django-redis-4.9.0/debian/control 2018-03-03 18:40:09.000000000 +0000 +++ django-redis-4.10.0/debian/control 2018-11-28 19:39:31.000000000 +0000 @@ -12,7 +12,7 @@ python-setuptools, python3-all, python3-setuptools, -Standards-Version: 4.1.3 +Standards-Version: 4.2.1 Vcs-Browser: https://salsa.debian.org/python-team/modules/django-redis Vcs-Git: https://salsa.debian.org/python-team/modules/django-redis.git Homepage: https://github.com/niwinz/django-redis diff -Nru django-redis-4.9.0/django_redis/cache.py django-redis-4.10.0/django_redis/cache.py --- django-redis-4.9.0/django_redis/cache.py 2017-10-27 07:01:40.000000000 +0000 +++ django-redis-4.10.0/django_redis/cache.py 2018-11-19 08:48:56.000000000 +0000 @@ -80,7 +80,7 @@ return self.client.get(key, default=default, version=version, client=client) except ConnectionInterrupted as e: - if DJANGO_REDIS_IGNORE_EXCEPTIONS or self._ignore_exceptions: + if self._ignore_exceptions: if DJANGO_REDIS_LOG_IGNORED_EXCEPTIONS: logger.error(str(e)) return default @@ -150,3 +150,7 @@ @omit_exception def close(self, **kwargs): self.client.close(**kwargs) + + @omit_exception + def touch(self, key, timeout=None, version=None): + return self.client.touch(key, timeout=timeout, version=version) diff -Nru django-redis-4.9.0/django_redis/client/default.py django-redis-4.10.0/django_redis/client/default.py --- django-redis-4.9.0/django_redis/client/default.py 2018-03-01 10:02:22.000000000 +0000 +++ django-redis-4.10.0/django_redis/client/default.py 2018-11-19 08:48:56.000000000 +0000 @@ -34,8 +34,9 @@ self._server = server self._params = params - self.reverse_key = get_key_func(params.get("REVERSE_KEY_FUNCTION") or - "django_redis.util.default_reverse_key") + self.reverse_key = get_key_func( + params.get("REVERSE_KEY_FUNCTION") or "django_redis.util.default_reverse_key" + ) if not self._server: raise ImproperlyConfigured("Missing connections string") @@ -472,7 +473,7 @@ key = self.make_key(key, version=version) try: - return client.exists(key) + return client.exists(key) == 1 except _main_exceptions as e: raise ConnectionInterrupted(connection=client, parent=e) @@ -540,3 +541,15 @@ for c in self._clients[i].connection_pool._available_connections: c.disconnect() self._clients[i] = None + + def touch(self, key, timeout=DEFAULT_TIMEOUT, version=None, client=None): + """ + Sets a new expiration for a key. + """ + + if client is None: + client = self.get_client(write=True) + + key = self.make_key(key, version=version) + + return client.expire(key, timeout) diff -Nru django-redis-4.9.0/django_redis/client/sharded.py django-redis-4.10.0/django_redis/client/sharded.py --- django-redis-4.9.0/django_redis/client/sharded.py 2018-03-01 10:02:22.000000000 +0000 +++ django-redis-4.10.0/django_redis/client/sharded.py 2018-11-19 08:48:56.000000000 +0000 @@ -118,7 +118,7 @@ key = self.make_key(key, version=version) try: - return client.exists(key) + return client.exists(key) == 1 except ConnectionError: raise ConnectionInterrupted(connection=client) diff -Nru django-redis-4.9.0/django_redis/__init__.py django-redis-4.10.0/django_redis/__init__.py --- django-redis-4.9.0/django_redis/__init__.py 2018-03-01 10:30:03.000000000 +0000 +++ django-redis-4.10.0/django_redis/__init__.py 2018-11-19 08:49:09.000000000 +0000 @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -VERSION = (4, 9, 0) +VERSION = (4, 10, 0) __version__ = '.'.join(map(str, VERSION)) diff -Nru django-redis-4.9.0/django_redis/util.py django-redis-4.10.0/django_redis/util.py --- django-redis-4.9.0/django_redis/util.py 2017-10-27 07:01:40.000000000 +0000 +++ django-redis-4.10.0/django_redis/util.py 2018-11-19 08:48:56.000000000 +0000 @@ -5,23 +5,15 @@ from importlib import import_module from django.core.exceptions import ImproperlyConfigured -from django.utils.encoding import python_2_unicode_compatible, smart_text +from django.utils import six -@python_2_unicode_compatible -class CacheKey(object): +class CacheKey(six.text_type): """ A stub string class that we can use to check if a key was created already. """ - def __init__(self, key): - self._key = key - - def __str__(self): - return smart_text(self._key) - def original_key(self): - key = self._key.rsplit(":", 1)[1] - return key + return self.rsplit(":", 1)[1] def load_class(path): diff -Nru django-redis-4.9.0/django_redis.egg-info/PKG-INFO django-redis-4.10.0/django_redis.egg-info/PKG-INFO --- django-redis-4.9.0/django_redis.egg-info/PKG-INFO 2018-03-01 10:30:52.000000000 +0000 +++ django-redis-4.10.0/django_redis.egg-info/PKG-INFO 2018-11-19 15:56:16.000000000 +0000 @@ -1,12 +1,11 @@ Metadata-Version: 1.2 Name: django-redis -Version: 4.9.0 +Version: 4.10.0 Summary: Full featured redis cache backend for Django. Home-page: https://github.com/niwibe/django-redis Author: Andrei Antoukh Author-email: niwi@niwi.nz License: UNKNOWN -Description-Content-Type: UNKNOWN Description: UNKNOWN Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable @@ -14,6 +13,7 @@ Classifier: Framework :: Django Classifier: Framework :: Django :: 1.11 Classifier: Framework :: Django :: 2.0 +Classifier: Framework :: Django :: 2.1 Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent @@ -24,6 +24,7 @@ Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 +Classifier: Programming Language :: Python :: 3.7 Classifier: Topic :: Software Development :: Libraries Classifier: Topic :: Utilities Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* diff -Nru django-redis-4.9.0/django_redis.egg-info/SOURCES.txt django-redis-4.10.0/django_redis.egg-info/SOURCES.txt --- django-redis-4.9.0/django_redis.egg-info/SOURCES.txt 2018-03-01 10:30:52.000000000 +0000 +++ django-redis-4.10.0/django_redis.egg-info/SOURCES.txt 2018-11-19 15:56:16.000000000 +0000 @@ -36,6 +36,7 @@ doc/content-docinfo.html doc/content.adoc doc/index.html +doc/dist/latest/index.html tests/README.txt tests/__init__.py tests/runtests-herd.py diff -Nru django-redis-4.9.0/doc/content.adoc django-redis-4.10.0/doc/content.adoc --- django-redis-4.9.0/doc/content.adoc 2018-03-01 10:02:22.000000000 +0000 +++ django-redis-4.10.0/doc/content.adoc 2018-11-19 08:56:22.000000000 +0000 @@ -1,7 +1,7 @@ django-redis documentation ========================== Andrey Antukh, -4.8.0 +4.10.0 :toc: left :numbered: :source-highlighter: pygments @@ -38,18 +38,17 @@ Supported django-redis versions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- Supported stable version: *4.8.0* -- Supported stable version: *3.8.4* +- Supported stable version: *4.10.0* How version number is handled ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Versions like _3.6_, _3.7_, ... are considered major releases +Versions like _4.6_, _4.7_, ... are considered major releases and can contain some backward incompatibilities. For more information is very recommended see the changelog before update. -Versions like _3.7.0_, _3.7.1_, ... are considered minor or bug +Versions like _4.7.0_, _4.7.1_, ... are considered minor or bug fix releases and are should contain only bug fixes. No new features. @@ -65,7 +64,6 @@ Redis Server Support ^^^^^^^^^^^^^^^^^^^^ -- *django-redis 3.x.y* will maintain support for redis-server 2.6.x and upper. - *django-redis 4.x.y* will maintain support for redis-server 2.8.x and upper. @@ -106,8 +104,8 @@ } ---- -django-redis, since 3.8.0, it starts using redis-py native url notation for connection strings, -that allows better interoperability and have a connection string in more "standard" way. +django-redis uses the redis-py native url notation for connection strings, +it allows better interoperability and has a connection string in more "standard" way. .This is a examples of url format ---- @@ -232,7 +230,7 @@ Compression support ~~~~~~~~~~~~~~~~~~~ -_django_redis_ comes with compression support out of the box, but is deactivated by default. +_django_redis_ comes with compression support out of the box, but is deactivated by default. You can activate it setting up a concrete backend: @@ -508,15 +506,15 @@ Configure default connection pool ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The default connection pool is simple. You can only customize the maximum number of connections -in the pool, by setting `CONNECTION_POOL_KWARGS` in the `CACHES` setting: +The default connection pool is simple. For example, you can customize the maximum number of connections +in the pool by setting `CONNECTION_POOL_KWARGS` in the `CACHES` setting: [source, python] ---- CACHES = { "default": { "BACKEND": "django_redis.cache.RedisCache", - ... + # ... "OPTIONS": { "CONNECTION_POOL_KWARGS": {"max_connections": 100} } @@ -529,7 +527,6 @@ [source, python] ---- -from django.core.cache import get_cache from django_redis import get_redis_connection r = get_redis_connection("default") # Use the name you have defined for Redis in settings.CACHES @@ -537,6 +534,21 @@ print("Created connections so far: %d" % connection_pool._created_connections) ---- +Since the default connection pool passes all keyword arguments it doesn't use to its connections, you can also customize the connections that the pool makes by adding those options to `CONNECTION_POOL_KWARGS`: + +[source, python] +---- +CACHES = { + "default": { + # ... + "OPTIONS": { + "CONNECTION_POOL_KWARGS": {"max_connections": 100, "retry_on_timeout": True} + } + } +} +---- + + Use your own connection pool subclass ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff -Nru django-redis-4.9.0/doc/dist/latest/index.html django-redis-4.10.0/doc/dist/latest/index.html --- django-redis-4.9.0/doc/dist/latest/index.html 1970-01-01 00:00:00.000000000 +0000 +++ django-redis-4.10.0/doc/dist/latest/index.html 2018-11-19 09:33:34.000000000 +0000 @@ -0,0 +1,1114 @@ + + + + + + + + +django-redis documentation + + + + + + +
+
+

1. Introduction

+
+
+

django-redis is a BSD Licensed, full featured Redis cache/session backend for Django.

+
+
+

1.1. Why use django-redis?

+
+

Because:

+
+
+
    +
  • +

    In active development.

    +
  • +
  • +

    Uses native redis-py url notation connection strings.

    +
  • +
  • +

    Pluggable clients.

    +
  • +
  • +

    Pluggable parsers.

    +
  • +
  • +

    Pluggable serializers.

    +
  • +
  • +

    Master-Slave support in the default client.

    +
  • +
  • +

    Complete battery of tests.

    +
  • +
  • +

    Used in production in several projects as cache and session storage.

    +
  • +
  • +

    Supports infinite timeouts.

    +
  • +
  • +

    Facilities for raw access to Redis client/connection pool.

    +
  • +
  • +

    Highly configurable (can emulate memcached exception behavior, for example).

    +
  • +
  • +

    Unix sockets supported by default.

    +
  • +
  • +

    With support for python 2.7, 3.4, 3.5 and 3.6

    +
  • +
+
+
+
+

1.2. Supported django-redis versions

+
+
    +
  • +

    Supported stable version: 4.10.0

    +
  • +
+
+
+
+

1.3. How version number is handled

+
+

Versions like 4.6, 4.7, …​ are considered major releases +and can contain some backward incompatibilities. For more information +is very recommended see the changelog before update.

+
+
+

Versions like 4.7.0, 4.7.1, …​ are considered minor or bug +fix releases and are should contain only bug fixes. No new features.

+
+
+
+

1.4. Requirements

+
+

1.4.1. Django version support

+
+
    +
  • +

    django-redis supports Django 1.11+.

    +
  • +
+
+
+
+

1.4.2. Redis Server Support

+
+
    +
  • +

    django-redis 4.x.y will maintain support for redis-server 2.8.x and upper.

    +
  • +
+
+
+
+

1.4.3. Other requirements

+
+

All supported versions of django-redis depends on redis-py >= 2.10.0.

+
+
+
+
+
+
+

2. User guide

+
+
+

2.1. Installation

+
+

The simplest way to use django-redis in your project is to install it with pip:

+
+
+
+
pip install django-redis
+
+
+
+
+

2.2. Configure as cache backend

+
+

To start using django-redis, you should change your Django cache settings to something like this:

+
+
+
+
CACHES = {
+    "default": {
+        "BACKEND": "django_redis.cache.RedisCache",
+        "LOCATION": "redis://127.0.0.1:6379/1",
+        "OPTIONS": {
+            "CLIENT_CLASS": "django_redis.client.DefaultClient",
+        }
+    }
+}
+
+
+
+

django-redis uses the redis-py native url notation for connection strings, +it allows better interoperability and has a connection string in more "standard" way.

+
+
+
This is a examples of url format
+
+
redis://[:password]@localhost:6379/0
+rediss://[:password]@localhost:6379/0
+unix://[:password]@/path/to/socket.sock?db=0
+
+
+
+

Three URL schemes are supported:

+
+
+
    +
  • +

    redis://: creates a normal TCP socket connection

    +
  • +
  • +

    rediss://: creates a SSL wrapped TCP socket connection

    +
  • +
  • +

    unix:// creates a Unix Domain Socket connection

    +
  • +
+
+
+

There are several ways to specify a database number:

+
+
+
    +
  • +

    A db querystring option, e.g. redis://localhost?db=0

    +
  • +
  • +

    If using the redis:// scheme, the path argument of the url, e.g. redis://localhost/0

    +
  • +
+
+
+

In some circumstances the password you should use to connect redis +is not URL-safe, in this case you can escape it or just use the +convenience option in OPTIONS dict:

+
+
+
+
CACHES = {
+    "default": {
+        "BACKEND": "django_redis.cache.RedisCache",
+        "LOCATION": "redis://127.0.0.1:6379/1",
+        "OPTIONS": {
+            "CLIENT_CLASS": "django_redis.client.DefaultClient",
+            "PASSWORD": "mysecret"
+        }
+    }
+}
+
+
+
+

Take care, that this option does not overwrites the password in the uri, so if you +have set the password in the uri, this settings will be ignored.

+
+
+
+

2.3. Configure as session backend

+
+

Django can by default use any cache backend as session backend and you benefit from that by using +django-redis as backend for session storage without installing any additional backends:

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

2.4. Testing with django-redis

+
+

django-redis supports customizing the underlying Redis client (see +Pluggable redis client). This can be used for testing purposes, e.g., by +replacing the default client with mockredis +(https://github.com/locationlabs/mockredis). Doing so allows you to run your +integration tests without depending on a real Redis server.

+
+
+

In case you want to flush all data from the cache after a test, add the +following lines to your TestCase:

+
+
+
+
def tearDown(self):
+    from django_redis import get_redis_connection
+    get_redis_connection("default").flushall()
+
+
+
+
+
+
+

3. Advanced usage

+
+
+

3.1. Pickle version

+
+

For almost all values, django-redis uses pickle to serialize objects.

+
+
+

The latest available version of pickle is used by default. If you want set a concrete version, you +can do it, using PICKLE_VERSION option:

+
+
+
+
CACHES = {
+    "default": {
+        # ...
+        "OPTIONS": {
+            "PICKLE_VERSION": -1  # Use the latest protocol version
+        }
+    }
+}
+
+
+
+
+

3.2. Socket timeout

+
+

Socket timeout can be set using SOCKET_TIMEOUT and SOCKET_CONNECT_TIMEOUT +options:

+
+
+
+
CACHES = {
+    "default": {
+        # ...
+        "OPTIONS": {
+            "SOCKET_CONNECT_TIMEOUT": 5,  # in seconds
+            "SOCKET_TIMEOUT": 5,  # in seconds
+        }
+    }
+}
+
+
+
+

SOCKET_CONNECT_TIMEOUT is the timeout for the connection to be established and +SOCKET_TIMEOUT is the timeout for read and write operations after the connection +is established.

+
+
+
+

3.3. Compression support

+
+

django_redis comes with compression support out of the box, but is deactivated by default. +You can activate it setting up a concrete backend:

+
+
+
+
CACHES = {
+    "default": {
+        # ...
+        "OPTIONS": {
+            "COMPRESSOR": "django_redis.compressors.zlib.ZlibCompressor",
+        }
+    }
+}
+
+
+
+

Let see an example, of how make it work with lzma compression format:

+
+
+
+
import lzma
+
+CACHES = {
+    "default": {
+        # ...
+        "OPTIONS": {
+            "COMPRESSOR": "django_redis.compressors.lzma.LzmaCompressor",
+        }
+    }
+}
+
+
+
+

Lz4 compression support (requires the lz4 library):

+
+
+
+
import lz4
+
+CACHES = {
+    "default": {
+        # ...
+        "OPTIONS": {
+            "COMPRESSOR": "django_redis.compressors.lz4.Lz4Compressor",
+        }
+    }
+}
+
+
+
+
+

3.4. Memcached exceptions behavior

+
+

In some situations, when Redis is only used for cache, you do not want exceptions when Redis is down. +This is default behavior in the memcached backend and it can be emulated in django-redis.

+
+
+

For setup memcached like behaviour (ignore connection exceptions), you should +set IGNORE_EXCEPTIONS settings on your cache configuration:

+
+
+
+
CACHES = {
+    "default": {
+        # ...
+        "OPTIONS": {
+            "IGNORE_EXCEPTIONS": True,
+        }
+    }
+}
+
+
+
+

Also, you can apply the same settings to all configured caches, you can set the global flag in +your settings:

+
+
+
+
DJANGO_REDIS_IGNORE_EXCEPTIONS = True
+
+
+
+
+

3.5. Log Ignored Exceptions

+
+

When ignoring exceptions with IGNORE_EXCEPTIONS or DJANGO_REDIS_IGNORE_EXCEPTIONS, +you may optionally log exceptions using the global variable DJANGO_REDIS_LOG_IGNORED_EXCEPTIONS +in your settings file.

+
+
+
+
DJANGO_REDIS_LOG_IGNORED_EXCEPTIONS = True
+
+
+
+

If you wish to specify the logger in which the exceptions are output, simply set the global +variable DJANGO_REDIS_LOGGER to the string name and/or path of the desired logger. This will +default to __name__ if no logger is specified and DJANGO_REDIS_LOG_IGNORED_EXCEPTIONS is True

+
+
+
+
DJANGO_REDIS_LOGGER = 'some.specified.logger'
+
+
+
+
+

3.6. Infinite timeout

+
+

django-redis comes with infinite timeouts support out of the box. And it behaves in same way +as django backend contract specifies:

+
+
+
    +
  • +

    timeout=0 expires the value immediately.

    +
  • +
  • +

    timeout=None infinite timeout

    +
  • +
+
+
+
+
cache.set("key", "value", timeout=None)
+
+
+
+
+

3.7. Get ttl (time-to-live) from key

+
+

With redis, you can access to ttl of any stored key, for it, django-redis exposes ttl function.

+
+
+

It returns:

+
+
+
    +
  • +

    0 if key does not exists (or already expired).

    +
  • +
  • +

    None for keys that exists but does not have any expiration.

    +
  • +
  • +

    ttl value for any volatile key (any key that has expiration).

    +
  • +
+
+
+
Simple search keys by pattern
+
+
>>> from django.core.cache import cache
+>>> cache.set("foo", "value", timeout=25)
+>>> cache.ttl("foo")
+25
+>>> cache.ttl("not-existent")
+0
+
+
+
+
+

3.8. Expire & Persist

+
+

Additionally to the simple ttl query, you can send persist a concrete key or specify +a new expiration timeout using the persist and expire methods:

+
+
+
Example using persist method
+
+
>>> cache.set("foo", "bar", timeout=22)
+>>> cache.ttl("foo")
+22
+>>> cache.persist("foo")
+>>> cache.ttl("foo")
+None
+
+
+
+
Example using expire method
+
+
>>> cache.set("foo", "bar", timeout=22)
+>>> cache.expire("foo", timeout=5)
+>>> cache.ttl("foo")
+5
+
+
+
+
+

3.9. Locks

+
+

It also supports the redis ability to create redis distributed named locks. The Lock +interface is identical to the threading.Lock so you can use it as replacement.

+
+
+
Example allocating a lock using python context managers facilities.
+
+
with cache.lock("somekey"):
+    do_some_thing()
+
+
+
+
+

3.10. Scan & Delete keys in bulk

+
+

django-redis comes with some additional methods that help with searching or deleting keys +using glob patterns.

+
+
+
Simple search keys by pattern
+
+
>>> from django.core.cache import cache
+>>> cache.keys("foo_*")
+["foo_1", "foo_2"]
+
+
+
+

A simple search like this will return all matched values. In databases with a large number of keys +this isn’t suitable method. Instead, you can use the iter_keys function that works like the keys +function but uses redis>=2.8 server side cursors. Calling iter_keys will return a generator that +you can then iterate over efficiently.

+
+
+
Search using server side cursors
+
+
>>> from django.core.cache import cache
+>>> cache.iter_keys("foo_*")
+<generator object algo at 0x7ffa9c2713a8>
+>>> next(cache.iter_keys("foo_*"))
+"foo_1"
+
+
+
+

For deleting keys, you should use delete_pattern which has the same glob pattern syntax +as the keys function and returns the number of deleted keys.

+
+
+
Example use of delete_pattern
+
+
>>> from django.core.cache import cache
+>>> cache.delete_pattern("foo_*")
+
+
+
+
+

3.11. Redis native commands

+
+

django-redis has limited support for some Redis atomic operations, such as the commands SETNX + and INCR.

+
+
+

You can use the SETNX command through the backend set() method with the nx parameter:

+
+
+
Example:
+
+
>>> from django.core.cache import cache
+>>> cache.set("key", "value1", nx=True)
+True
+>>> cache.set("key", "value2", nx=True)
+False
+>>> cache.get("key")
+"value1"
+
+
+
+

Also, incr and decr methods uses redis atomic operations when value that contains a key is suitable +for it.

+
+
+
+

3.12. Raw client access

+
+

In some situations your application requires access to a raw Redis client to use some advanced +features that aren’t exposed by the Django cache interface. To avoid storing another setting for +creating a raw connection, django-redis exposes functions with which you can obtain a raw client +reusing the cache connection string: get_redis_connection(alias).

+
+
+
+
>>> from django_redis import get_redis_connection
+>>> con = get_redis_connection("default")
+>>> con
+<redis.client.StrictRedis object at 0x2dc4510>
+
+
+
+ + + + + +
+
Warning
+
+Not all pluggable clients support this feature. +
+
+
+
+

3.13. Connection pools

+
+

Behind the scenes, django-redis uses the underlying redis-py connection pool implementation, +and exposes a simple way to configure it. Alternatively, you can directly customize a +connection/connection pool creation for a backend.

+
+
+

The default redis-py behavior is to not close connections, recycling them when possible.

+
+
+

3.13.1. Configure default connection pool

+
+

The default connection pool is simple. For example, you can customize the maximum number of connections +in the pool by setting CONNECTION_POOL_KWARGS in the CACHES setting:

+
+
+
+
CACHES = {
+    "default": {
+        "BACKEND": "django_redis.cache.RedisCache",
+        # ...
+        "OPTIONS": {
+            "CONNECTION_POOL_KWARGS": {"max_connections": 100}
+        }
+    }
+}
+
+
+
+

You can verify how many connections the pool has opened with the following snippet:

+
+
+
+
from django_redis import get_redis_connection
+
+r = get_redis_connection("default")  # Use the name you have defined for Redis in settings.CACHES
+connection_pool = r.connection_pool
+print("Created connections so far: %d" % connection_pool._created_connections)
+
+
+
+

Since the default connection pool passes all keyword arguments it doesn’t use to its connections, you can also customize the connections that the pool makes by adding those options to CONNECTION_POOL_KWARGS:

+
+
+
+
CACHES = {
+    "default": {
+        # ...
+        "OPTIONS": {
+            "CONNECTION_POOL_KWARGS": {"max_connections": 100, "retry_on_timeout": True}
+        }
+    }
+}
+
+
+
+
+

3.13.2. Use your own connection pool subclass

+
+

Sometimes you want to use your own subclass of the connection pool. This is possible with +django-redis using the CONNECTION_POOL_CLASS parameter in the backend options.

+
+
+
myproj/mypool.py
+
+
from redis.connection import ConnectionPool
+
+class MyOwnPool(ConnectionPool):
+    # Just doing nothing, only for example purpose
+    pass
+
+
+
+
settings.py
+
+
# Omitting all backend declaration boilerplate code.
+
+"OPTIONS": {
+    "CONNECTION_POOL_CLASS": "myproj.mypool.MyOwnPool",
+}
+
+
+
+
+

3.13.3. Customize connection factory

+
+

If none of the previous methods satisfies you, you can get in the middle of the +django-redis connection factory process and customize or completely rewrite it.

+
+
+

By default, django-redis creates connections through the django_redis.pool.ConnectionFactory +class that is specified in the global Django setting DJANGO_REDIS_CONNECTION_FACTORY.

+
+
+
Partial interface of ConnectionFactory class
+
+
# Note: Using Python 3 notation for code documentation ;)
+
+class ConnectionFactory(object):
+    def get_connection_pool(self, params:dict):
+        # Given connection parameters in the `params` argument,
+        # return new connection pool.
+        # It should be overwritten if you want do something
+        # before/after creating the connection pool, or return your
+        # own connection pool.
+        pass
+
+    def get_connection(self, params:dict):
+        # Given connection parameters in the `params` argument,
+        # return a new connection.
+        # It should be overwritten if you want to do something
+        # before/after creating a new connection.
+        # The default implementation uses `get_connection_pool`
+        # to obtain a pool and create a new connection in the
+        # newly obtained pool.
+        pass
+
+    def get_or_create_connection_pool(self, params:dict):
+        # This is a high layer on top of `get_connection_pool` for
+        # implementing a cache of created connection pools.
+        # It should be overwritten if you want change the default
+        # behavior.
+        pass
+
+    def make_connection_params(self, url:str) -> dict:
+        # The responsibility of this method is to convert basic connection
+        # parameters and other settings to fully connection pool ready
+        # connection parameters.
+        pass
+
+    def connect(self, url:str):
+        # This is really a public API and entry point for this
+        # factory class. This encapsulates the main logic of creating
+        # the previously mentioned `params` using `make_connection_params`
+        # and creating a new connection using the `get_connection` method.
+        pass
+
+
+
+
+
+

3.14. Pluggable parsers

+
+

redis-py (the Python Redis client used by django-redis) comes with a pure Python Redis parser +that works very well for most common task, but if you want some performance boost, you can use +hiredis.

+
+
+

hiredis is a Redis client written in C and it has its own parser that can be used with django-redis.

+
+
+
+
"OPTIONS": {
+    "PARSER_CLASS": "redis.connection.HiredisParser",
+}
+
+
+
+
+

3.15. Pluggable clients

+
+

django_redis is designed for to be very flexible and very configurable. For it, it exposes a +pluggable backends that make easy extend the default behavior, and it comes with few ones +out the box.

+
+
+

3.15.1. Default client

+
+

Almost all about the default client is explained, with one exception: the default client comes +with master-slave support.

+
+
+

To connect to master-slave redis setup, you should change the LOCATION to something like this:

+
+
+
+
"LOCATION": [
+    "redis://127.0.0.1:6379/1",
+    "redis://127.0.0.1:6378/1",
+]
+
+
+
+

The first connection string represents a master server and the rest to slave servers.

+
+
+ + + + + +
+
Warning
+
+Master-Slave setup is not heavily tested in production environments. +
+
+
+
+

3.15.2. Shard client

+
+

This pluggable client implements client-side sharding. It inherits almost all functionality from +the default client. To use it, change your cache settings to something like this:

+
+
+
+
CACHES = {
+    "default": {
+        "BACKEND": "django_redis.cache.RedisCache",
+        "LOCATION": [
+            "redis://127.0.0.1:6379/1",
+            "redis://127.0.0.1:6379/2",
+        ],
+        "OPTIONS": {
+            "CLIENT_CLASS": "django_redis.client.ShardClient",
+        }
+    }
+}
+
+
+
+ + + + + +
+
Warning
+
+Shard client is still experimental, so be careful when using it in production environments. +
+
+
+
+

3.15.3. Herd client

+
+

This pluggable client helps dealing with the thundering herd problem. You can read more about it +on Wikipedia.

+
+
+

Like previous pluggable clients, it inherits all functionality from the default client, adding some +additional methods for getting/setting keys.

+
+
+
Example setup
+
+
 CACHES = {
+    "default": {
+        "BACKEND": "django_redis.cache.RedisCache",
+        "LOCATION": "redis://127.0.0.1:6379/1",
+        "OPTIONS": {
+            "CLIENT_CLASS": "django_redis.client.HerdClient",
+        }
+    }
+}
+
+
+
+

This client exposes additional settings:

+
+
+
    +
  • +

    CACHE_HERD_TIMEOUT: Set default herd timeout. (Default value: 60s)

    +
  • +
+
+
+
+
+

3.16. Pluggable serializer

+
+

The pluggable clients serialize data before sending it to the +server. By default, django_redis serialize the data using Python +pickle. This is very flexible and can handle a large range of object +types.

+
+
+

To serialize using JSON instead, the serializer JSONSerializer is +also available.

+
+
+
Example setup
+
+
 CACHES = {
+    "default": {
+        "BACKEND": "django_redis.cache.RedisCache",
+        "LOCATION": "redis://127.0.0.1:6379/1",
+        "OPTIONS": {
+            "CLIENT_CLASS": "django_redis.client.DefaultClient",
+            "SERIALIZER": "django_redis.serializers.json.JSONSerializer",
+        }
+    }
+}
+
+
+
+

There’s also support for serialization using MsgPack http://msgpack.org/ +(that requires the msgpack-python library):

+
+
+
Example setup
+
+
 CACHES = {
+    "default": {
+        "BACKEND": "django_redis.cache.RedisCache",
+        "LOCATION": "redis://127.0.0.1:6379/1",
+        "OPTIONS": {
+            "CLIENT_CLASS": "django_redis.client.DefaultClient",
+            "SERIALIZER": "django_redis.serializers.msgpack.MSGPackSerializer",
+        }
+    }
+}
+
+
+
+
+

3.17. Pluggable redis client

+
+

django_redis uses the Redis client redis.client.StrictClient by default. It +is possible to use an alternative client.

+
+
+

You can customize the client used by setting REDIS_CLIENT_CLASS in the +CACHES setting. Optionally, you can provide arguments to this class +by setting REDIS_CLIENT_KWARGS.

+
+
+
Example setup
+
+
CACHES = {
+    "default": {
+        "OPTIONS": {
+            "REDIS_CLIENT_CLASS": "my.module.ClientClass",
+            "REDIS_CLIENT_KWARGS": {"some_setting": True},
+        }
+    }
+}
+
+
+
+
+
+
+

4. License

+
+
+
+
Copyright (c) 2011-2015 Andrey Antukh <niwi@niwi.nz>
+Copyright (c) 2011 Sean Bleier
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote products
+   derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+
+
+
+ + + \ No newline at end of file diff -Nru django-redis-4.9.0/PKG-INFO django-redis-4.10.0/PKG-INFO --- django-redis-4.9.0/PKG-INFO 2018-03-01 10:30:52.000000000 +0000 +++ django-redis-4.10.0/PKG-INFO 2018-11-19 15:56:16.000000000 +0000 @@ -1,12 +1,11 @@ Metadata-Version: 1.2 Name: django-redis -Version: 4.9.0 +Version: 4.10.0 Summary: Full featured redis cache backend for Django. Home-page: https://github.com/niwibe/django-redis Author: Andrei Antoukh Author-email: niwi@niwi.nz License: UNKNOWN -Description-Content-Type: UNKNOWN Description: UNKNOWN Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable @@ -14,6 +13,7 @@ Classifier: Framework :: Django Classifier: Framework :: Django :: 1.11 Classifier: Framework :: Django :: 2.0 +Classifier: Framework :: Django :: 2.1 Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent @@ -24,6 +24,7 @@ Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 +Classifier: Programming Language :: Python :: 3.7 Classifier: Topic :: Software Development :: Libraries Classifier: Topic :: Utilities Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* diff -Nru django-redis-4.9.0/README.rst django-redis-4.10.0/README.rst --- django-redis-4.9.0/README.rst 2017-01-24 10:07:37.000000000 +0000 +++ django-redis-4.10.0/README.rst 2018-11-19 08:48:56.000000000 +0000 @@ -8,7 +8,7 @@ :target: https://travis-ci.org/niwinz/django-redis .. image:: https://img.shields.io/pypi/v/django-redis.svg?style=flat - :target: https://pypi.python.org/pypi/django-redis + :target: https://pypi.org/project/django-redis/ Documentation diff -Nru django-redis-4.9.0/setup.py django-redis-4.10.0/setup.py --- django-redis-4.9.0/setup.py 2018-03-01 10:02:22.000000000 +0000 +++ django-redis-4.10.0/setup.py 2018-11-19 08:48:56.000000000 +0000 @@ -35,6 +35,7 @@ "Framework :: Django", "Framework :: Django :: 1.11", "Framework :: Django :: 2.0", + "Framework :: Django :: 2.1", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", @@ -45,6 +46,7 @@ "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries", "Topic :: Utilities", ], diff -Nru django-redis-4.9.0/tests/test_backend.py django-redis-4.10.0/tests/test_backend.py --- django-redis-4.9.0/tests/test_backend.py 2018-03-01 10:02:22.000000000 +0000 +++ django-redis-4.10.0/tests/test_backend.py 2018-11-19 08:48:56.000000000 +0000 @@ -16,6 +16,7 @@ from django.test import override_settings from django.test.utils import patch_logger from django.utils import six, timezone +from redis.exceptions import ConnectionError import django_redis.cache from django_redis import pool @@ -545,10 +546,8 @@ def test_ttl(self): cache = caches["default"] _params = cache._params - _is_herd = (_params["OPTIONS"]["CLIENT_CLASS"] == - "django_redis.client.HerdClient") - _is_shard = (_params["OPTIONS"]["CLIENT_CLASS"] == - "django_redis.client.ShardClient") + _is_herd = _params["OPTIONS"]["CLIENT_CLASS"] == "django_redis.client.HerdClient" + _is_shard = _params["OPTIONS"]["CLIENT_CLASS"] == "django_redis.client.ShardClient" # Not supported for shard client. if _is_shard: @@ -601,8 +600,7 @@ def test_iter_keys(self): cache = caches["default"] _params = cache._params - _is_shard = (_params["OPTIONS"]["CLIENT_CLASS"] == - "django_redis.client.ShardClient") + _is_shard = _params["OPTIONS"]["CLIENT_CLASS"] == "django_redis.client.ShardClient" if _is_shard: return @@ -635,13 +633,41 @@ except NotImplementedError: pass + def test_touch_zero_timeout(self): + self.cache.set("test_key", 222, timeout=10) + + self.assertEqual(self.cache.touch("test_key", 0), True) + res = self.cache.get("test_key", None) + self.assertEqual(res, None) + + def test_touch_positive_timeout(self): + self.cache.set("test_key", 222, timeout=10) + + self.cache.touch("test_key", 2) + self.assertEqual(self.cache.touch("test_key", 2), True) + res1 = self.cache.get("test_key", None) + time.sleep(2) + res2 = self.cache.get("test_key", None) + self.assertEqual(res1, 222) + self.assertEqual(res2, None) + + def test_touch_negative_timeout(self): + self.cache.set("test_key", 222, timeout=10) + + self.assertEqual(self.cache.touch("test_key", -1), True) + res = self.cache.get("test_key", None) + self.assertEqual(res, None) + + def test_touch_missed_key(self): + self.assertEqual(self.cache.touch("test_key", -1), False) + class DjangoOmitExceptionsTests(unittest.TestCase): def setUp(self): self._orig_setting = django_redis.cache.DJANGO_REDIS_IGNORE_EXCEPTIONS django_redis.cache.DJANGO_REDIS_IGNORE_EXCEPTIONS = True caches_setting = copy.deepcopy(settings.CACHES) - caches_setting["doesnotexist"]["IGNORE_EXCEPTIONS"] = True + caches_setting["doesnotexist"]["OPTIONS"]["IGNORE_EXCEPTIONS"] = True cm = override_settings(CACHES=caches_setting) cm.enable() self.addCleanup(cm.disable) @@ -651,14 +677,55 @@ django_redis.cache.DJANGO_REDIS_IGNORE_EXCEPTIONS = self._orig_setting def test_get_many_returns_default_arg(self): + self.assertIs(self.cache._ignore_exceptions, True) self.assertEqual(self.cache.get_many(["key1", "key2", "key3"]), {}) def test_get(self): + self.assertIs(self.cache._ignore_exceptions, True) self.assertIsNone(self.cache.get("key")) self.assertEqual(self.cache.get("key", "default"), "default") self.assertEqual(self.cache.get("key", default="default"), "default") +class DjangoOmitExceptionsPriority1Tests(unittest.TestCase): + def setUp(self): + self._orig_setting = django_redis.cache.DJANGO_REDIS_IGNORE_EXCEPTIONS + django_redis.cache.DJANGO_REDIS_IGNORE_EXCEPTIONS = False + caches_setting = copy.deepcopy(settings.CACHES) + caches_setting["doesnotexist"]["OPTIONS"]["IGNORE_EXCEPTIONS"] = True + cm = override_settings(CACHES=caches_setting) + cm.enable() + self.addCleanup(cm.disable) + self.cache = caches["doesnotexist"] + + def tearDown(self): + django_redis.cache.DJANGO_REDIS_IGNORE_EXCEPTIONS = self._orig_setting + + def test_get(self): + self.assertIs(self.cache._ignore_exceptions, True) + self.assertIsNone(self.cache.get("key")) + + +class DjangoOmitExceptionsPriority2Tests(unittest.TestCase): + def setUp(self): + self._orig_setting = django_redis.cache.DJANGO_REDIS_IGNORE_EXCEPTIONS + django_redis.cache.DJANGO_REDIS_IGNORE_EXCEPTIONS = True + caches_setting = copy.deepcopy(settings.CACHES) + caches_setting["doesnotexist"]["OPTIONS"]["IGNORE_EXCEPTIONS"] = False + cm = override_settings(CACHES=caches_setting) + cm.enable() + self.addCleanup(cm.disable) + self.cache = caches["doesnotexist"] + + def tearDown(self): + django_redis.cache.DJANGO_REDIS_IGNORE_EXCEPTIONS = self._orig_setting + + def test_get(self): + self.assertIs(self.cache._ignore_exceptions, False) + with self.assertRaises(ConnectionError): + self.cache.get("key") + + # Copied from Django's sessions test suite. Keep in sync with upstream. # https://github.com/django/django/blob/master/tests/sessions_tests/tests.py class SessionTestsMixin: @@ -935,7 +1002,7 @@ self.assertEqual(self.session.decode(encoded), data) def test_decode_failure_logged_to_security(self): - bad_encode = base64.b64encode(b'flaskdj:alkdjf') + bad_encode = base64.b64encode(b'flaskdj:alkdjf').decode() with patch_logger('django.security.SuspiciousSession', 'warning') as calls: self.assertEqual({}, self.session.decode(bad_encode)) # check that the failed decode is logged diff -Nru django-redis-4.9.0/tests/test_sqlite_herd.py django-redis-4.10.0/tests/test_sqlite_herd.py --- django-redis-4.9.0/tests/test_sqlite_herd.py 2018-03-01 10:02:22.000000000 +0000 +++ django-redis-4.10.0/tests/test_sqlite_herd.py 2018-11-19 08:48:56.000000000 +0000 @@ -10,11 +10,11 @@ 'CLIENT_CLASS': 'django_redis.client.HerdClient', } }, - 'doesnotexist': { - 'BACKEND': 'django_redis.cache.RedisCache', - 'LOCATION': '127.0.0.1:56379:1', - 'OPTIONS': { - 'CLIENT_CLASS': 'django_redis.client.HerdClient', + "doesnotexist": { + "BACKEND": "django_redis.cache.RedisCache", + "LOCATION": "redis://127.0.0.1:56379?db=1", + "OPTIONS": { + "CLIENT_CLASS": "django_redis.client.HerdClient", } }, 'sample': { diff -Nru django-redis-4.9.0/tests/test_sqlite_json.py django-redis-4.10.0/tests/test_sqlite_json.py --- django-redis-4.9.0/tests/test_sqlite_json.py 2018-03-01 10:02:22.000000000 +0000 +++ django-redis-4.10.0/tests/test_sqlite_json.py 2018-11-19 08:48:56.000000000 +0000 @@ -14,7 +14,7 @@ }, "doesnotexist": { "BACKEND": "django_redis.cache.RedisCache", - "LOCATION": "127.0.0.1:56379:1", + "LOCATION": "redis://127.0.0.1:56379?db=1", "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", "SERIALIZER": "django_redis.serializers.json.JSONSerializer", diff -Nru django-redis-4.9.0/tests/test_sqlite_lz4.py django-redis-4.10.0/tests/test_sqlite_lz4.py --- django-redis-4.9.0/tests/test_sqlite_lz4.py 2018-03-01 10:02:22.000000000 +0000 +++ django-redis-4.10.0/tests/test_sqlite_lz4.py 2018-11-19 08:48:56.000000000 +0000 @@ -14,7 +14,7 @@ }, "doesnotexist": { "BACKEND": "django_redis.cache.RedisCache", - "LOCATION": "127.0.0.1:56379:1", + "LOCATION": "redis://127.0.0.1:56379?db=1", "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", "COMPRESSOR": "django_redis.compressors.lz4.Lz4Compressor", diff -Nru django-redis-4.9.0/tests/test_sqlite_msgpack.py django-redis-4.10.0/tests/test_sqlite_msgpack.py --- django-redis-4.9.0/tests/test_sqlite_msgpack.py 2018-03-01 10:02:22.000000000 +0000 +++ django-redis-4.10.0/tests/test_sqlite_msgpack.py 2018-11-19 08:48:56.000000000 +0000 @@ -14,7 +14,7 @@ }, "doesnotexist": { "BACKEND": "django_redis.cache.RedisCache", - "LOCATION": "127.0.0.1:56379:1", + "LOCATION": "redis://127.0.0.1:56379?db=1", "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", "SERIALIZER": "django_redis.serializers.msgpack.MSGPackSerializer", diff -Nru django-redis-4.9.0/tests/test_sqlite.py django-redis-4.10.0/tests/test_sqlite.py --- django-redis-4.9.0/tests/test_sqlite.py 2018-03-01 10:02:22.000000000 +0000 +++ django-redis-4.10.0/tests/test_sqlite.py 2018-11-19 08:48:56.000000000 +0000 @@ -13,7 +13,7 @@ }, "doesnotexist": { "BACKEND": "django_redis.cache.RedisCache", - "LOCATION": "127.0.0.1:56379:1", + "LOCATION": "redis://127.0.0.1:56379?db=1", "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", } diff -Nru django-redis-4.9.0/tests/test_sqlite_sharding.py django-redis-4.10.0/tests/test_sqlite_sharding.py --- django-redis-4.9.0/tests/test_sqlite_sharding.py 2018-03-01 10:02:22.000000000 +0000 +++ django-redis-4.10.0/tests/test_sqlite_sharding.py 2018-11-19 08:48:56.000000000 +0000 @@ -14,8 +14,8 @@ 'doesnotexist': { 'BACKEND': 'django_redis.cache.RedisCache', 'LOCATION': [ - '127.0.0.1:56379:1', - '127.0.0.1:56379:2', + "redis://127.0.0.1:56379?db=1", + "redis://127.0.0.1:56379?db=2", ], 'OPTIONS': { 'CLIENT_CLASS': 'django_redis.client.ShardClient', diff -Nru django-redis-4.9.0/tests/test_sqlite_usock.py django-redis-4.10.0/tests/test_sqlite_usock.py --- django-redis-4.9.0/tests/test_sqlite_usock.py 2018-03-01 10:02:22.000000000 +0000 +++ django-redis-4.10.0/tests/test_sqlite_usock.py 2018-11-19 08:48:56.000000000 +0000 @@ -13,7 +13,7 @@ }, 'doesnotexist': { 'BACKEND': 'redis_cache.cache.RedisCache', - 'LOCATION': '127.0.0.1:56379:1', + 'LOCATION': 'redis://127.0.0.1:56379?db=1', 'OPTIONS': { 'CLIENT_CLASS': 'redis_cache.client.DefaultClient', } diff -Nru django-redis-4.9.0/tests/test_sqlite_zlib.py django-redis-4.10.0/tests/test_sqlite_zlib.py --- django-redis-4.9.0/tests/test_sqlite_zlib.py 2018-03-01 10:02:22.000000000 +0000 +++ django-redis-4.10.0/tests/test_sqlite_zlib.py 2018-11-19 08:48:56.000000000 +0000 @@ -14,7 +14,7 @@ }, "doesnotexist": { "BACKEND": "django_redis.cache.RedisCache", - "LOCATION": "127.0.0.1:56379:1", + "LOCATION": "redis://127.0.0.1:56379?db=1", "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", "COMPRESSOR": "django_redis.compressors.zlib.ZlibCompressor",