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
4bc27036
Commit
4bc27036
authored
May 11, 2010
by
Jannis Leidel
Committed by
Sean Bleier
May 12, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A few cosmetic changes.
parent
686cd3fc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
cache.py
redis_cache/cache.py
+10
-7
No files found.
redis_cache/cache.py
View file @
4bc27036
...
...
@@ -28,10 +28,10 @@ class CacheClass(BaseCache):
return
value
def
add
(
self
,
key
,
value
,
timeout
=
0
):
"""Add a value to the cache, failing if the key already exists.
"""
Add a value to the cache, failing if the key already exists.
Returns ``True`` if the object was added, ``False`` if not.
"""
if
self
.
_cache
.
exists
(
key
):
...
...
@@ -40,10 +40,10 @@ class CacheClass(BaseCache):
return
self
.
set
(
key
,
value
,
timeout
)
def
get
(
self
,
key
,
default
=
None
):
"""Retrieve a value from the cache.
"""
Retrieve a value from the cache.
Returns unpicked value if key is found, ``None`` if not.
"""
key
=
self
.
_prepare_key
(
key
)
...
...
@@ -66,11 +66,12 @@ class CacheClass(BaseCache):
return
value
def
set
(
self
,
key
,
value
,
timeout
=
None
):
"Persist a value to the cache, and set an optional expiration time."
key
=
self
.
_prepare_key
(
key
)
value
=
self
.
_prepare_value
(
value
)
"""
Persist a value to the cache, and set an optional expiration time.
"""
# pickle the value
value
=
pickle
.
dumps
(
value
)
.
encode
(
'base64'
)
...
...
@@ -108,5 +109,7 @@ class CacheClass(BaseCache):
return
self
.
_cache
.
decr
(
key
,
delta
)
def
close
(
self
,
**
kwargs
):
"Disconnect from the cache."
"""
Disconnect from the cache.
"""
self
.
_cache
.
connection
.
disconnect
()
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