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
ab084443
Commit
ab084443
authored
Jan 10, 2012
by
mucca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow to have multiple connections
parent
49b05036
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
cache.py
redis_cache/cache.py
+7
-4
No files found.
redis_cache/cache.py
View file @
ab084443
...
@@ -38,12 +38,15 @@ class CacheKey(object):
...
@@ -38,12 +38,15 @@ class CacheKey(object):
class
CacheConnectionPool
(
object
):
class
CacheConnectionPool
(
object
):
_connection_pool
=
None
def
__init__
(
self
):
self
.
_connection_pools
=
{}
def
get_connection_pool
(
self
,
host
=
'127.0.0.1'
,
port
=
6379
,
db
=
1
,
def
get_connection_pool
(
self
,
host
=
'127.0.0.1'
,
port
=
6379
,
db
=
1
,
password
=
None
,
parser_class
=
None
,
password
=
None
,
parser_class
=
None
,
unix_socket_path
=
None
):
unix_socket_path
=
None
):
if
self
.
_connection_pool
is
None
:
connection_identifier
=
(
host
,
port
,
db
,
parser_class
,
unix_socket_path
)
if
not
self
.
_connection_pools
.
get
(
connection_identifier
):
connection_class
=
(
connection_class
=
(
unix_socket_path
and
UnixDomainSocketConnection
or
Connection
unix_socket_path
and
UnixDomainSocketConnection
or
Connection
)
)
...
@@ -60,8 +63,8 @@ class CacheConnectionPool(object):
...
@@ -60,8 +63,8 @@ class CacheConnectionPool(object):
})
})
else
:
else
:
kwargs
[
'path'
]
=
unix_socket_path
kwargs
[
'path'
]
=
unix_socket_path
self
.
_connection_pool
=
redis
.
ConnectionPool
(
**
kwargs
)
self
.
_connection_pool
s
[
connection_identifier
]
=
redis
.
ConnectionPool
(
**
kwargs
)
return
self
.
_connection_pool
return
self
.
_connection_pool
s
[
connection_identifier
]
pool
=
CacheConnectionPool
()
pool
=
CacheConnectionPool
()
...
...
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