Skip to content

Commit 47e7a5c

Browse files
authored
Merge pull request #1 from sebleier/master
update head repo master branch
2 parents 7eb7d63 + 0b1f870 commit 47e7a5c

File tree

17 files changed

+281
-189
lines changed

17 files changed

+281
-189
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ MANIFEST
1919
.venv
2020
redis/
2121
*/_build/
22+
build/*

.travis.yml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
1+
dist: xenial
12
language: python
23
python:
34
- 2.7
4-
- 3.3
5-
- 3.4
65
- 3.5
6+
- 3.6
7+
- 3.7
78
env:
8-
- DJANGO_VERSION='>=1.8a1,<1.9'
9-
- DJANGO_VERSION='>=1.9a1,<1.10'
10-
- DJANGO_VERSION='>=1.10a1,<1.11'
9+
- DJANGO_VERSION='<2.0'
10+
- DJANGO_VERSION='>=2.0,<2.1'
11+
- DJANGO_VERSION='>=2.1,<2.2'
12+
- DJANGO_VERSION='==2.2b1'
1113
matrix:
1214
exclude:
13-
- python: 3.3
14-
env: DJANGO_VERSION='>=1.9a1,<1.10'
15-
- python: 3.3
16-
env: DJANGO_VERSION='>=1.10a1,<1.11'
15+
- python: 2.7
16+
env: DJANGO_VERSION='>=2.0,<2.1'
17+
- python: 2.7
18+
env: DJANGO_VERSION='>=2.1,<2.2'
19+
- python: 2.7
20+
env: DJANGO_VERSION='==2.2b1'
21+
- python: 3.5
22+
env: DJANGO_VERSION='<2.0'
23+
- python: 3.6
24+
env: DJANGO_VERSION='<2.0'
25+
- python: 3.7
26+
env: DJANGO_VERSION='<2.0'
1727
# command to run tests
1828
install: ./install_redis.sh
1929
script: make test DJANGO_VERSION=$DJANGO_VERSION

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@
2222
| Martey Dodoo / martey <https://github.com/martey>
2323
| Joona Pääkkönen / paksu <https://github.com/paksu>
2424
| Tim Graham / timgraham <https://github.com/timgraham>
25+
| Justin Arulnathan / dinie <[email protected]>

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
SHELL := /bin/bash
22

33
PACKAGE_NAME=redis_cache
4-
DJANGO_VERSION?=>=1.10a1,<1.11
4+
DJANGO_VERSION?=>=1.11,<3.0
55

66
.PHONY: install_requirements
77
install_requirements: requirements*.txt

README.rst

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Redis Django Cache Backend
33
==========================
44

5-
.. image:: https://img.shields.io/pypi/dm/django-redis-cache.svg
6-
:target: https://pypi.python.org/pypi//django-redis-cache/
5+
.. image:: https://pepy.tech/badge/django-redis-cache
6+
:target: https://pepy.tech/project/django-redis-cache
77
:alt: Downloads
88

99
.. image:: https://img.shields.io/pypi/v/django-redis-cache.svg
@@ -21,6 +21,23 @@ Docs can be found at http://django-redis-cache.readthedocs.org/en/latest/.
2121
Changelog
2222
=========
2323

24+
2.0.0
25+
-----
26+
27+
* Adds support for redis-py >= 3.0.
28+
* Drops support for Redis 2.6.
29+
* Drops support for Python 3.4.
30+
* Removes custom ``expire`` method in lieu of Django's ``touch``.
31+
* Removes ``CacheKey`` in favor of string literals.
32+
* Adds testing for Django 2.2 and Python 3.7 (no code changes required).
33+
34+
35+
1.8.0
36+
-----
37+
38+
* Confirms support for Django 1.11, 2.0, and 2.1 (no code changes required).
39+
* Drops support for Django < 1.11.
40+
2441
1.7.1
2542
-----
2643

docs/api.rst

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ Standard Django Cache API
9393
:param version: Version of key
9494
:type version: Integer or None
9595

96+
.. function:: touch(self, key, timeout):
97+
98+
Updates the timeout on a key.
99+
100+
:param key: Location of the value
101+
:rtype: bool
102+
96103

97104

98105
Cache Methods Provided by django-redis-cache
@@ -124,14 +131,22 @@ Cache Methods Provided by django-redis-cache
124131
:param version: Version of the keys
125132

126133

127-
.. function:: get_or_set(self, key, func[, timeout=None]):
134+
.. function:: get_or_set(self, key, func[, timeout=None, lock_timeout=None, stale_cache_timeout=None]):
135+
136+
Get a value from the cache or call ``func`` to set it and return it.
128137

129-
Retrieves a key value from the cache and sets the value if it does not exist.
138+
This implementation is slightly more advanced that Django's. It provides thundering herd
139+
protection, which prevents multiple threads/processes from calling the value-generating
140+
function at the same time.
130141

131142
:param key: Location of the value
132143
:param func: Callable used to set the value if key does not exist.
133-
:param timeout: Number of seconds to hold value in cache.
144+
:param timeout: Time in seconds that value at key is considered fresh.
134145
:type timeout: Number of seconds or None
146+
:param lock_timeout: Time in seconds that the lock will stay active and prevent other threads from acquiring the lock.
147+
:type lock_timeout: Number of seconds or None
148+
:param stale_cache_timeout: Time in seconds that the stale cache will remain after the key has expired. If ``None`` is specified, the stale value will remain indefinitely.
149+
:type stale_cache_timeout: Number of seconds or None
135150

136151

137152
.. function:: reinsert_keys(self):
@@ -147,12 +162,9 @@ Cache Methods Provided by django-redis-cache
147162
:param key: Location of the value
148163
:rtype: bool
149164

165+
.. function:: lock(self, key, timeout=None, sleep=0.1, blocking_timeout=None, thread_local=True)
150166

151-
.. function:: expire(self, key, timeout):
152-
153-
Set the expire time on a key
154-
155-
:param key: Location of the value
156-
:rtype: bool
167+
See docs for `redis-py`_.
157168

158169

170+
.. _redis-py: https://redis-py.readthedocs.io/en/latest/_modules/redis/client.html#Redis.lock

docs/intro_quick_start.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Intro and Quick Start
44
Intro
55
=====
66

7-
`django-redis-cache`_ is a cache backend for the `Django`_ webframework. It
7+
`django-redis-cache`_ is a cache backend for the `Django`_ web framework. It
88
uses the `redis`_ server, which is a in-memory key-value data structure server.
99
Similar to the great `Memcached`_ in performance, it has several features that
1010
makes it more appealing.
@@ -24,7 +24,7 @@ makes it more appealing.
2424
* Many more.
2525

2626
Many of these features are irrelevant to caching, but can be used by other
27-
areas of a web stack and therefore offer a compelling case to simplify your
27+
areas of a web stack and therefore offers a compelling case to simplify your
2828
infrastructure.
2929

3030

@@ -35,9 +35,9 @@ Quick Start
3535

3636
**Recommended:**
3737

38-
* `redis`_ >= 2.4
38+
* `redis`_ >= 2.8
3939

40-
* `redis-py`_ >= 2.10.3
40+
* `redis-py`_ >= 3.0.0
4141

4242
* `python`_ >= 2.7
4343

@@ -58,6 +58,8 @@ of redis. Start the server by running ``./src/redis-server``
5858
},
5959
}
6060
61+
**Warning: By default, django-redis-cache set keys in the database 1 of Redis. By default, a session with redis-cli start on database 0. Switch to database 1 with** ``SELECT 1``.
62+
6163
.. _Django: https://www.djangoproject.com/
6264
.. _django-redis-cache: http://github.com/sebleier/django-redis-cache
6365
.. _redis-py: http://github.com/andymccurdy/redis-py/

install_redis.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
: ${REDIS_VERSION:="2.6"}
3+
: ${REDIS_VERSION:="4.0.11"}
44

55
test -d redis || git clone https://github.com/antirez/redis
66
git -C redis checkout $REDIS_VERSION

0 commit comments

Comments
 (0)