Permalink
Browse files

Split the rendercache and pagecache.

The pagecache and rendercache have very different usage profiles.
  • Loading branch information...
1 parent b201405 commit 2d22cd2aa92dcb3cb0f891a4e2aff4608e0eccc8 @spladug spladug committed Dec 1, 2012
Showing with 21 additions and 8 deletions.
  1. +1 −2 r2/example.ini
  2. +2 −2 r2/r2/controllers/reddit_base.py
  3. +16 −2 r2/r2/lib/app_globals.py
  4. +2 −2 r2/r2/lib/pages/pages.py
View
@@ -148,9 +148,8 @@ memcaches = 127.0.0.1:11211
# caches to use for locking
lockcaches = 127.0.0.1:11211
stalecaches =
-# render caches (the second is "remote" and the local is optional but in the same format)
-local_rendercache =
rendercaches = 127.0.0.1:11211
+pagecaches = 127.0.0.1:11211
# -- permacache options --
# permacache is memcaches -> cassanda -> memcachedb
@@ -640,7 +640,7 @@ def pre(self):
def try_pagecache(self):
#check content cache
if request.method.upper() == 'GET' and not c.user_is_loggedin:
- r = g.rendercache.get(self.request_key())
+ r = g.pagecache.get(self.request_key())
if r:
r, c.cookies = r
response = c.response
@@ -698,7 +698,7 @@ def post(self):
and response.status_code not in (429, 503)
and response.content and response.content[0]):
try:
- g.rendercache.set(self.request_key(),
+ g.pagecache.set(self.request_key(),
(response, c.cookies),
g.page_cache_time)
except MemcachedError as e:
@@ -170,6 +170,7 @@ class Globals(object):
'lockcaches',
'permacache_memcaches',
'rendercaches',
+ 'pagecaches',
'cassandra_seeds',
'admins',
'sponsors',
@@ -416,15 +417,22 @@ def setup(self):
else:
stalecaches = None
- # rendercache holds rendered partial templates as well as fully
- # cached pages.
+ # rendercache holds rendered partial templates.
rendercaches = CMemcache(
self.rendercaches,
noreply=True,
no_block=True,
num_clients=num_mc_clients,
)
+ # pagecaches hold fully rendered pages
+ pagecaches = CMemcache(
+ self.pagecaches,
+ noreply=True,
+ no_block=True,
+ num_clients=num_mc_clients,
+ )
+
self.startup_timer.intermediate("memcache")
################# CASSANDRA
@@ -485,6 +493,12 @@ def setup(self):
))
self.cache_chains.update(rendercache=self.rendercache)
+ self.pagecache = MemcacheChain((
+ localcache_cls(),
+ pagecaches,
+ ))
+ self.cache_chains.update(pagecache=self.pagecache)
+
# the thing_cache is used in tdb_cassandra.
self.thing_cache = CacheChain((localcache_cls(),))
self.cache_chains.update(thing_cache=self.thing_cache)
@@ -1180,7 +1180,7 @@ def renderer():
if try_cache:
# try to fetch the comment tree from the cache
key = self.cache_key()
- self.rendered = g.rendercache.get(key)
+ self.rendered = g.pagecache.get(key)
if not self.rendered:
# spoof an unlogged in user
user = c.user
@@ -1194,7 +1194,7 @@ def renderer():
# render as if not logged in (but possibly with reply buttons)
self.rendered = renderer().render()
- g.rendercache.set(
+ g.pagecache.set(
key,
self.rendered,
time=g.commentpane_cache_time

0 comments on commit 2d22cd2

Please sign in to comment.