Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
Django-Redis-Cache
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shared
Django-Redis-Cache
Commits
558c2a4b
Commit
558c2a4b
authored
Apr 09, 2015
by
Sean Bleier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make update for django 1.8.
parent
8e9d345a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
13 deletions
+29
-13
cache.py
redis_cache/cache.py
+8
-3
tcptests.py
tcptests.py
+15
-6
tests.py
tests/testapp/tests.py
+6
-4
No files found.
redis_cache/cache.py
View file @
558c2a4b
from
django.core.cache.backends.base
import
BaseCache
,
InvalidCacheBackendError
from
django.core.cache.backends.base
import
BaseCache
,
InvalidCacheBackendError
from
django.core.exceptions
import
ImproperlyConfigured
from
django.core.exceptions
import
ImproperlyConfigured
from
django.utils
import
importlib
from
django.utils.datastructures
import
SortedDict
from
django.utils.datastructures
import
SortedDict
from
.compat
import
(
smart_text
,
smart_bytes
,
bytes_type
,
from
.compat
import
(
smart_text
,
smart_bytes
,
bytes_type
,
python_2_unicode_compatible
,
DEFAULT_TIMEOUT
)
python_2_unicode_compatible
,
DEFAULT_TIMEOUT
)
try
:
import
importlib
except
ImportError
:
from
django.utils
import
importlib
try
:
try
:
import
cPickle
as
pickle
import
cPickle
as
pickle
except
ImportError
:
except
ImportError
:
...
@@ -49,8 +53,9 @@ class CacheConnectionPool(object):
...
@@ -49,8 +53,9 @@ class CacheConnectionPool(object):
password
=
None
,
parser_class
=
None
,
password
=
None
,
parser_class
=
None
,
unix_socket_path
=
None
,
connection_pool_class
=
None
,
unix_socket_path
=
None
,
connection_pool_class
=
None
,
connection_pool_class_kwargs
=
None
):
connection_pool_class_kwargs
=
None
):
connection_identifier
=
(
host
,
port
,
db
,
parser_class
,
unix_socket_path
,
connection_pool_class
)
connection_identifier
=
(
host
,
port
,
db
,
unix_socket_path
)
if
not
self
.
_connection_pools
.
get
(
connection_identifier
):
pool
=
self
.
_connection_pools
.
get
(
connection_identifier
)
if
pool
is
None
:
connection_class
=
(
connection_class
=
(
unix_socket_path
and
UnixDomainSocketConnection
or
Connection
unix_socket_path
and
UnixDomainSocketConnection
or
Connection
)
)
...
...
tcptests.py
View file @
558c2a4b
#!/usr/bin/env python
#!/usr/bin/env python
import
sys
import
sys
from
os.path
import
dirname
,
abspath
from
os.path
import
dirname
,
abspath
,
join
import
django
from
django.conf
import
settings
from
django.conf
import
settings
...
@@ -10,8 +11,9 @@ cache_settings = {
...
@@ -10,8 +11,9 @@ cache_settings = {
'ENGINE'
:
'django.db.backends.sqlite3'
,
'ENGINE'
:
'django.db.backends.sqlite3'
,
}
}
},
},
'MIDDLEWARE_CLASSES'
:(),
'INSTALLED_APPS'
:
[
'INSTALLED_APPS'
:
[
'test
s.test
app'
,
'testapp'
,
],
],
'ROOT_URLCONF'
:
'tests.urls'
,
'ROOT_URLCONF'
:
'tests.urls'
,
'CACHES'
:
{
'CACHES'
:
{
...
@@ -34,14 +36,21 @@ cache_settings = {
...
@@ -34,14 +36,21 @@ cache_settings = {
if
not
settings
.
configured
:
if
not
settings
.
configured
:
settings
.
configure
(
**
cache_settings
)
settings
.
configure
(
**
cache_settings
)
from
django.test.simple
import
DjangoTestSuiteRunner
try
:
from
django.test.simple
import
DjangoTestSuiteRunner
as
TestSuiteRunner
except
ImportError
:
from
django.test.runner
import
DiscoverRunner
as
TestSuiteRunner
def
runtests
(
*
test_args
):
def
runtests
(
*
test_args
):
if
not
test_args
:
if
not
test_args
:
test_args
=
[
'testapp'
]
test_args
=
[
'testapp'
]
parent
=
dirname
(
abspath
(
__file__
))
sys
.
path
.
insert
(
0
,
join
(
dirname
(
abspath
(
__file__
)),
'tests'
))
sys
.
path
.
insert
(
0
,
parent
)
try
:
runner
=
DjangoTestSuiteRunner
(
verbosity
=
1
,
interactive
=
True
,
failfast
=
False
)
django
.
setup
()
except
AttributeError
:
pass
runner
=
TestSuiteRunner
(
verbosity
=
1
,
interactive
=
True
,
failfast
=
False
)
failures
=
runner
.
run_tests
(
test_args
)
failures
=
runner
.
run_tests
(
test_args
)
sys
.
exit
(
failures
)
sys
.
exit
(
failures
)
...
...
tests/testapp/tests.py
View file @
558c2a4b
...
@@ -45,8 +45,10 @@ class RedisCacheTests(TestCase):
...
@@ -45,8 +45,10 @@ class RedisCacheTests(TestCase):
def
get_cache
(
self
,
backend
=
None
):
def
get_cache
(
self
,
backend
=
None
):
if
VERSION
[
0
]
==
1
and
VERSION
[
1
]
<
3
:
if
VERSION
[
0
]
==
1
and
VERSION
[
1
]
<
3
:
cache
=
get_cache
(
backend
or
'redis_cache.cache://127.0.0.1:6379?db=15'
)
cache
=
get_cache
(
backend
or
'redis_cache.cache://127.0.0.1:6379?db=15'
)
elif
VERSION
[
0
]
==
1
and
VERSION
[
1
]
>=
3
:
elif
VERSION
[
0
]
==
1
and
VERSION
[
1
]
>=
3
and
VERSION
[
1
]
<=
7
:
cache
=
get_cache
(
backend
or
'default'
)
cache
=
get_cache
(
backend
or
'default'
)
else
:
cache
=
get_cache
(
backend
or
'redis_cache.cache.CacheClass'
,
LOCATION
=
'127.0.0.1:6379'
)
return
cache
return
cache
def
test_bad_db_initialization
(
self
):
def
test_bad_db_initialization
(
self
):
...
@@ -356,11 +358,11 @@ class RedisCacheTests(TestCase):
...
@@ -356,11 +358,11 @@ class RedisCacheTests(TestCase):
def
test_multiple_connection_pool_connections
(
self
):
def
test_multiple_connection_pool_connections
(
self
):
pool
.
_connection_pools
=
{}
pool
.
_connection_pools
=
{}
get_cache
(
'redis_cache.cache
://127.0.0.1:6379?db=15'
)
get_cache
(
'redis_cache.cache
.CacheClass'
,
LOCATION
=
'127.0.0.1:6379'
,
OPTIONS
=
{
'DB'
:
15
}
)
self
.
assertEqual
(
len
(
pool
.
_connection_pools
),
1
)
self
.
assertEqual
(
len
(
pool
.
_connection_pools
),
1
)
get_cache
(
'redis_cache.cache
://127.0.0.1:6379?db=14'
)
get_cache
(
'redis_cache.cache
.CacheClass'
,
LOCATION
=
'127.0.0.1:6379'
,
OPTIONS
=
{
'DB'
:
14
}
)
self
.
assertEqual
(
len
(
pool
.
_connection_pools
),
2
)
self
.
assertEqual
(
len
(
pool
.
_connection_pools
),
2
)
get_cache
(
'redis_cache.cache
://127.0.0.1:6379?db=15'
)
get_cache
(
'redis_cache.cache
.CacheClass'
,
LOCATION
=
'127.0.0.1:6379'
,
OPTIONS
=
{
'DB'
:
15
}
)
self
.
assertEqual
(
len
(
pool
.
_connection_pools
),
2
)
self
.
assertEqual
(
len
(
pool
.
_connection_pools
),
2
)
def
test_setting_string_integer_retrieves_string
(
self
):
def
test_setting_string_integer_retrieves_string
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment