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
5945ea9c
Commit
5945ea9c
authored
Jul 27, 2011
by
Sean Bleier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug with 'get_many' not handling integers correctly.
parent
70877eb9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
cache.py
redis_cache/cache.py
+7
-1
tests.py
tests/testapp/tests.py
+14
-0
No files found.
redis_cache/cache.py
View file @
5945ea9c
...
...
@@ -28,6 +28,9 @@ class CacheKey(object):
def
__str__
(
self
):
return
self
.
__unicode__
()
def
__repr__
(
self
):
return
self
.
__unicode__
()
def
__unicode__
(
self
):
return
smart_str
(
self
.
_key
)
...
...
@@ -162,6 +165,9 @@ class CacheClass(BaseCache):
for
key
,
value
in
zip
(
new_keys
,
results
):
if
value
is
None
:
continue
try
:
value
=
int
(
value
)
except
(
ValueError
,
TypeError
):
value
=
self
.
unpickle
(
value
)
if
isinstance
(
value
,
basestring
):
value
=
smart_unicode
(
value
)
...
...
tests/testapp/tests.py
View file @
5945ea9c
...
...
@@ -83,6 +83,20 @@ class RedisCacheTests(TestCase):
self
.
assertEqual
(
self
.
cache
.
get_many
([
'a'
,
'c'
,
'd'
]),
{
'a'
:
'a'
,
'c'
:
'c'
,
'd'
:
'd'
})
self
.
assertEqual
(
self
.
cache
.
get_many
([
'a'
,
'b'
,
'e'
]),
{
'a'
:
'a'
,
'b'
:
'b'
})
def
test_get_many_with_manual_integer_insertion
(
self
):
keys
=
[
'a'
,
'b'
,
'c'
,
'd'
]
cache_keys
=
map
(
self
.
cache
.
make_key
,
keys
)
# manually set integers and then get_many
for
i
,
key
in
enumerate
(
cache_keys
):
self
.
cache
.
_client
.
set
(
key
,
i
)
self
.
assertEqual
(
self
.
cache
.
get_many
(
keys
),
{
'a'
:
0
,
'b'
:
1
,
'c'
:
2
,
'd'
:
3
})
def
test_get_many_with_automatic_integer_insertion
(
self
):
keys
=
[
'a'
,
'b'
,
'c'
,
'd'
]
for
i
,
key
in
enumerate
(
keys
):
self
.
cache
.
set
(
key
,
i
)
self
.
assertEqual
(
self
.
cache
.
get_many
(
keys
),
{
'a'
:
0
,
'b'
:
1
,
'c'
:
2
,
'd'
:
3
})
def
test_delete
(
self
):
# Cache keys can be deleted
self
.
cache
.
set
(
"key1"
,
"spam"
)
...
...
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