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
5dc7a9e1
Commit
5dc7a9e1
authored
Jul 19, 2015
by
Sean Bleier
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #87 from sebleier/unstable
Unstable
parents
ff014f34
079e9126
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
2 deletions
+52
-2
Makefile
Makefile
+1
-1
README.rst
README.rst
+5
-0
base.py
redis_cache/backends/base.py
+5
-0
connection.py
redis_cache/connection.py
+2
-0
setup.py
setup.py
+1
-1
socket_timeout_tests.py
tests/testapp/tests/socket_timeout_tests.py
+38
-0
No files found.
Makefile
View file @
5dc7a9e1
...
...
@@ -21,7 +21,7 @@ clean:
.PHONY
:
test
test
:
install_requirements
PYTHONPATH
=
$(PYTHONPATH)
: django-admin.py
test
--settings
=
tests.settings
-s
PYTHONPATH
=
$(PYTHONPATH)
: django-admin.py
test
tests.testapp.tests.socket_timeout_tests:SocketTimeoutTestCase.test_socket_timeout
--settings
=
tests.settings
-s
.PHONY
:
shell
shell
:
...
...
README.rst
View file @
5dc7a9e1
...
...
@@ -19,6 +19,11 @@ A Redis cache backend for Django
Changelog
=========
1.4.0
-----
* Adds support for providing a socket timeout on the redis-py client.
1.3.0
-----
...
...
redis_cache/backends/base.py
View file @
5dc7a9e1
...
...
@@ -55,6 +55,7 @@ class BaseRedisCache(BaseCache):
self
.
password
=
self
.
get_password
()
self
.
parser_class
=
self
.
get_parser_class
()
self
.
pickle_version
=
self
.
get_pickle_version
()
self
.
socket_timeout
=
self
.
get_socket_timeout
()
self
.
connection_pool_class
=
self
.
get_connection_pool_class
()
self
.
connection_pool_class_kwargs
=
(
self
.
get_connection_pool_class_kwargs
()
...
...
@@ -105,6 +106,9 @@ class BaseRedisCache(BaseCache):
except
(
ValueError
,
TypeError
):
raise
ImproperlyConfigured
(
"pickle version value must be an integer"
)
def
get_socket_timeout
(
self
):
return
self
.
options
.
get
(
'SOCKET_TIMEOUT'
,
None
)
def
get_connection_pool_class
(
self
):
pool_class
=
self
.
options
.
get
(
'CONNECTION_POOL_CLASS'
,
'redis.ConnectionPool'
)
module_name
,
class_name
=
pool_class
.
rsplit
(
'.'
,
1
)
...
...
@@ -153,6 +157,7 @@ class BaseRedisCache(BaseCache):
server
,
db
=
self
.
db
,
password
=
self
.
password
,
socket_timeout
=
self
.
socket_timeout
,
)
client
=
redis
.
Redis
(
**
kwargs
)
kwargs
.
update
(
...
...
redis_cache/connection.py
View file @
5dc7a9e1
...
...
@@ -30,6 +30,7 @@ class CacheConnectionPool(object):
unix_socket_path
=
None
,
connection_pool_class
=
None
,
connection_pool_class_kwargs
=
None
,
socket_timeout
=
None
,
**
kwargs
):
connection_identifier
=
(
host
,
port
,
db
,
unix_socket_path
)
...
...
@@ -48,6 +49,7 @@ class CacheConnectionPool(object):
'password'
:
password
,
'connection_class'
:
connection_class
,
'parser_class'
:
parser_class
,
'socket_timeout'
:
socket_timeout
,
}
kwargs
.
update
(
connection_pool_class_kwargs
)
...
...
setup.py
View file @
5dc7a9e1
...
...
@@ -5,7 +5,7 @@ setup(
url
=
"http://github.com/sebleier/django-redis-cache/"
,
author
=
"Sean Bleier"
,
author_email
=
"sebleier@gmail.com"
,
version
=
"1.
3
.0"
,
version
=
"1.
4
.0"
,
packages
=
[
"redis_cache"
,
"redis_cache.backends"
],
description
=
"Redis Cache Backend for Django"
,
install_requires
=
[
'redis>=2.10.3'
],
...
...
tests/testapp/tests/socket_timeout_tests.py
0 → 100644
View file @
5dc7a9e1
# -*- coding: utf-8 -*-
try
:
from
django.test
import
override_settings
except
ImportError
:
from
django.test.utils
import
override_settings
from
django.test
import
TestCase
from
redis.exceptions
import
ConnectionError
from
tests.testapp.tests.base_tests
import
SetupMixin
LOCATION
=
"127.0.0.1:6382"
@
override_settings
(
CACHES
=
{
'default'
:
{
'BACKEND'
:
'redis_cache.RedisCache'
,
'LOCATION'
:
LOCATION
,
'OPTIONS'
:
{
'DB'
:
15
,
'PASSWORD'
:
'yadayada'
,
'PARSER_CLASS'
:
'redis.connection.HiredisParser'
,
'PICKLE_VERSION'
:
-
1
,
'SOCKET_TIMEOUT'
:
0
,
},
},
}
)
class
SocketTimeoutTestCase
(
SetupMixin
,
TestCase
):
def
tearDown
(
self
):
pass
def
test_socket_timeout
(
self
):
self
.
reset_pool
()
cache
=
self
.
get_cache
()
with
self
.
assertRaises
(
ConnectionError
):
cache
.
set
(
'aaaaa'
,
'a'
)
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