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
05ba3ff6
Commit
05ba3ff6
authored
Nov 19, 2015
by
Sean Bleier
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #106 from triposo/master
Use default timeout in set_many.
parents
93ebff72
7c65c1a7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
multiple.py
redis_cache/backends/multiple.py
+4
-1
single.py
redis_cache/backends/single.py
+5
-1
No files found.
redis_cache/backends/multiple.py
View file @
05ba3ff6
from
collections
import
defaultdict
from
redis_cache.backends.base
import
BaseRedisCache
from
redis_cache.compat
import
DEFAULT_TIMEOUT
from
redis_cache.sharder
import
HashRing
...
...
@@ -71,7 +72,7 @@ class ShardedRedisCache(BaseRedisCache):
)
return
data
def
set_many
(
self
,
data
,
timeout
=
None
,
version
=
None
):
def
set_many
(
self
,
data
,
timeout
=
DEFAULT_TIMEOUT
,
version
=
None
):
"""
Set a bunch of values in the cache at once from a dict of key/value
pairs. This is much more efficient than calling set() multiple times.
...
...
@@ -79,6 +80,8 @@ class ShardedRedisCache(BaseRedisCache):
If timeout is given, that timeout will be used for the key; otherwise
the default cache timeout will be used.
"""
timeout
=
self
.
get_timeout
(
timeout
)
clients
=
self
.
shard
(
data
.
keys
(),
write
=
True
,
version
=
version
)
if
timeout
is
None
:
...
...
redis_cache/backends/single.py
View file @
05ba3ff6
from
redis_cache.compat
import
DEFAULT_TIMEOUT
try
:
import
cPickle
as
pickle
except
ImportError
:
...
...
@@ -52,7 +54,7 @@ class RedisCache(BaseRedisCache):
versioned_keys
=
self
.
make_keys
(
keys
,
version
=
version
)
return
self
.
_get_many
(
self
.
master_client
,
keys
,
versioned_keys
=
versioned_keys
)
def
set_many
(
self
,
data
,
timeout
=
None
,
version
=
None
):
def
set_many
(
self
,
data
,
timeout
=
DEFAULT_TIMEOUT
,
version
=
None
):
"""
Set a bunch of values in the cache at once from a dict of key/value
pairs. This is much more efficient than calling set() multiple times.
...
...
@@ -60,6 +62,8 @@ class RedisCache(BaseRedisCache):
If timeout is given, that timeout will be used for the key; otherwise
the default cache timeout will be used.
"""
timeout
=
self
.
get_timeout
(
timeout
)
versioned_keys
=
self
.
make_keys
(
data
.
keys
(),
version
=
version
)
if
timeout
is
None
:
new_data
=
{}
...
...
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