Skip to content

Commit

Permalink
Merge pull request #6 from kobotoolbox/django-gte-2.1
Browse files Browse the repository at this point in the history
Added Django 2.1+ support (also dropped older versions support)
  • Loading branch information
nezhar authored Dec 18, 2019
2 parents 62f1ed3 + c240abd commit 9734211
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
4 changes: 1 addition & 3 deletions django_request_cache/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from django.core.cache.backends.base import BaseCache
from django.core.cache.backends.locmem import LocMemCache
from django.utils.synch import RWLock
# coding: utf-8


def get_request_cache():
Expand Down
11 changes: 7 additions & 4 deletions django_request_cache/middleware.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# coding: utf-8
from collections import OrderedDict
from threading import Lock

from django.core.cache.backends.base import BaseCache
from django.core.cache.backends.locmem import LocMemCache
from django.utils.deprecation import MiddlewareMixin
from django.utils.synch import RWLock

# Attribution: RequestCache and RequestCacheMiddleware are from a source code snippet on StackOverflow
# https://stackoverflow.com/questions/3151469/per-request-cache-in-django/37015573#37015573
Expand All @@ -20,11 +23,11 @@ class RequestCache(LocMemCache):
def __init__(self):
# We explicitly do not call super() here, because while we want BaseCache.__init__() to run, we *don't*
# want LocMemCache.__init__() to run, because that would store our caches in its globals.
BaseCache.__init__(self, {})
BaseCache.__init__(self, params={})

self._cache = {}
self._cache = OrderedDict()
self._expire_info = {}
self._lock = RWLock()
self._lock = Lock()


class RequestCacheMiddleware(MiddlewareMixin):
Expand Down
17 changes: 7 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name='django-request-cache',
version='1.1',
version='1.2',
packages=find_packages(),
include_package_data=True,
license='MIT',
Expand All @@ -20,28 +20,25 @@
author='Christian Kreuzberger',
author_email='[email protected]',
install_requires=[
"django>=1.8,<2.1",
"django>=2.1",
"django_userforeignkey"
],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Framework :: Django',
'Framework :: Django :: 1.8',
'Framework :: Django :: 1.11',
'Framework :: Django :: 2.0',
'Framework :: Django :: 2.1',
'Framework :: Django :: 2.2',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
],
)
)

0 comments on commit 9734211

Please sign in to comment.