equal
deleted
inserted
replaced
27 |
27 |
28 import soc.cache.base |
28 import soc.cache.base |
29 |
29 |
30 |
30 |
31 def key(id): |
31 def key(id): |
32 """Returns the memcache key for the user's sidebar |
32 """Returns the memcache key for the user's sidebar. |
33 """ |
33 """ |
34 |
34 |
35 return 'sidebar_for_%s' % repr(id) |
35 return 'sidebar_for_%s' % repr(id) |
36 |
36 |
37 |
37 |
38 def get(id, user): |
38 def get(id, user): |
39 """Retrieves the sidebar for the specified user from the memcache |
39 """Retrieves the sidebar for the specified user from the memcache. |
40 """ |
40 """ |
41 |
41 |
42 memcache_key = key(id) |
42 memcache_key = key(id) |
43 return memcache.get(memcache_key) |
43 return memcache.get(memcache_key) |
44 |
44 |
45 |
45 |
46 def put(sidebar, id, user): |
46 def put(sidebar, id, user): |
47 """Sets the sidebar for the specified user in the memcache |
47 """Sets the sidebar for the specified user in the memcache. |
48 |
48 |
49 Args: |
49 Args: |
50 sidebar: the sidebar to be cached |
50 sidebar: the sidebar to be cached |
51 """ |
51 """ |
52 |
52 |
56 memcache_key = key(id) |
56 memcache_key = key(id) |
57 memcache.add(memcache_key, sidebar, retention) |
57 memcache.add(memcache_key, sidebar, retention) |
58 |
58 |
59 |
59 |
60 def flush(user=None): |
60 def flush(user=None): |
61 """Removes the sidebar for the current user from the memcache |
61 """Removes the sidebar for the current user from the memcache. |
62 |
62 |
63 Args: |
63 Args: |
64 user: defaults to the current user if not set |
64 user: defaults to the current user if not set |
65 """ |
65 """ |
66 |
66 |