mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-28 16:28:01 -05:00
Split the rendercache and pagecache.
The pagecache and rendercache have very different usage profiles.
This commit is contained in:
@@ -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 @@ class MinimalController(BaseController):
|
||||
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 @@ class MinimalController(BaseController):
|
||||
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,8 +417,7 @@ class Globals(object):
|
||||
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,
|
||||
@@ -425,6 +425,14 @@ class Globals(object):
|
||||
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 @@ class Globals(object):
|
||||
))
|
||||
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 @@ class CommentPane(Templated):
|
||||
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 @@ class CommentPane(Templated):
|
||||
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user