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
dd84fe45
Commit
dd84fe45
authored
May 11, 2010
by
Jannis Leidel
Committed by
Sean Bleier
May 12, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More cosmetic changes, yay.
parent
c6aab1bc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
cache.py
redis_cache/cache.py
+14
-5
No files found.
redis_cache/cache.py
View file @
dd84fe45
...
@@ -17,7 +17,9 @@ except:
...
@@ -17,7 +17,9 @@ except:
class
CacheClass
(
BaseCache
):
class
CacheClass
(
BaseCache
):
def
__init__
(
self
,
server
,
params
):
def
__init__
(
self
,
server
,
params
):
"Connect to Redis, and set up cache backend."
"""
Connect to Redis, and set up cache backend.
"""
BaseCache
.
__init__
(
self
,
params
)
BaseCache
.
__init__
(
self
,
params
)
self
.
_cache
=
redis
.
Redis
(
server
.
split
(
':'
)[
0
],
db
=
1
)
self
.
_cache
=
redis
.
Redis
(
server
.
split
(
':'
)[
0
],
db
=
1
)
...
@@ -62,19 +64,27 @@ class CacheClass(BaseCache):
...
@@ -62,19 +64,27 @@ class CacheClass(BaseCache):
def
expire
(
self
,
key
,
timeout
=
None
):
def
expire
(
self
,
key
,
timeout
=
None
):
"""
"""
s
et content expiration, if necessary
S
et content expiration, if necessary
"""
"""
timeout
=
timeout
or
self
.
default_timeout
timeout
=
timeout
or
self
.
default_timeout
self
.
_cache
.
expire
(
smart_str
(
key
),
timeout
)
self
.
_cache
.
expire
(
smart_str
(
key
),
timeout
)
def
delete
(
self
,
key
):
def
delete
(
self
,
key
):
"Remove a key from the cache."
"""
Remove a key from the cache.
"""
self
.
_cache
.
delete
(
smart_str
(
key
))
self
.
_cache
.
delete
(
smart_str
(
key
))
def
delete_many
(
self
,
keys
):
def
delete_many
(
self
,
keys
):
"""
Remove multiple keys at once.
"""
self
.
_cache
.
delete
(
*
map
(
smart_str
,
keys
))
self
.
_cache
.
delete
(
*
map
(
smart_str
,
keys
))
def
clear
(
self
):
def
clear
(
self
):
"""
Flush all cache keys.
"""
self
.
_cache
.
flushdb
()
self
.
_cache
.
flushdb
()
def
get_many
(
self
,
keys
):
def
get_many
(
self
,
keys
):
...
@@ -98,8 +108,7 @@ class CacheClass(BaseCache):
...
@@ -98,8 +108,7 @@ class CacheClass(BaseCache):
def
set_many
(
self
,
data
,
timeout
=
None
):
def
set_many
(
self
,
data
,
timeout
=
None
):
"""
"""
Set a bunch of values in the cache at once from a dict of key/value
Set a bunch of values in the cache at once from a dict of key/value
pairs. For certain backends (memcached), this is much more efficient
pairs. This is much more efficient than calling set() multiple times.
than calling set() multiple times.
If timeout is given, that timeout will be used for the key; otherwise
If timeout is given, that timeout will be used for the key; otherwise
the default cache timeout will be used.
the default cache timeout will be used.
...
...
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