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
7e1c3083
Commit
7e1c3083
authored
Mar 13, 2014
by
Markus Kaiserswerth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow timeout=None, fixes #62
parent
4a0911a5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
cache.py
redis_cache/cache.py
+5
-3
No files found.
redis_cache/cache.py
View file @
7e1c3083
...
@@ -208,7 +208,7 @@ class CacheClass(BaseCache):
...
@@ -208,7 +208,7 @@ class CacheClass(BaseCache):
return
result
return
result
def
_set
(
self
,
key
,
value
,
timeout
,
client
,
_add_only
=
False
):
def
_set
(
self
,
key
,
value
,
timeout
,
client
,
_add_only
=
False
):
if
timeout
==
0
:
if
timeout
is
None
or
timeout
==
0
:
if
_add_only
:
if
_add_only
:
return
client
.
setnx
(
key
,
value
)
return
client
.
setnx
(
key
,
value
)
return
client
.
set
(
key
,
value
)
return
client
.
set
(
key
,
value
)
...
@@ -231,12 +231,14 @@ class CacheClass(BaseCache):
...
@@ -231,12 +231,14 @@ class CacheClass(BaseCache):
key
=
self
.
make_key
(
key
,
version
=
version
)
key
=
self
.
make_key
(
key
,
version
=
version
)
if
timeout
is
DEFAULT_TIMEOUT
:
if
timeout
is
DEFAULT_TIMEOUT
:
timeout
=
self
.
default_timeout
timeout
=
self
.
default_timeout
if
timeout
is
not
None
:
timeout
=
int
(
timeout
)
# If ``value`` is not an int, then pickle it
# If ``value`` is not an int, then pickle it
if
not
isinstance
(
value
,
int
)
or
isinstance
(
value
,
bool
):
if
not
isinstance
(
value
,
int
)
or
isinstance
(
value
,
bool
):
result
=
self
.
_set
(
key
,
pickle
.
dumps
(
value
),
int
(
timeout
)
,
client
,
_add_only
)
result
=
self
.
_set
(
key
,
pickle
.
dumps
(
value
),
timeout
,
client
,
_add_only
)
else
:
else
:
result
=
self
.
_set
(
key
,
value
,
int
(
timeout
)
,
client
,
_add_only
)
result
=
self
.
_set
(
key
,
value
,
timeout
,
client
,
_add_only
)
# result is a boolean
# result is a boolean
return
result
return
result
...
...
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