cache processed HTML
The sanitizer is written in Python and rather slow for many comments
This commit is contained in:
parent
88689c789a
commit
a551271743
@ -262,6 +262,7 @@ class API(object):
|
|||||||
max_age=self.conf.getint('max-age'))
|
max_age=self.conf.getint('max-age'))
|
||||||
|
|
||||||
rv["text"] = self.isso.render(rv["text"])
|
rv["text"] = self.isso.render(rv["text"])
|
||||||
|
self.cache.set("text", str(id), rv["text"])
|
||||||
|
|
||||||
resp = JSON(rv, 200)
|
resp = JSON(rv, 200)
|
||||||
resp.headers.add("Set-Cookie", cookie(str(rv["id"])))
|
resp.headers.add("Set-Cookie", cookie(str(rv["id"])))
|
||||||
@ -289,6 +290,7 @@ class API(object):
|
|||||||
raise NotFound
|
raise NotFound
|
||||||
|
|
||||||
self.cache.delete('hash', (item['email'] or item['remote_addr']))
|
self.cache.delete('hash', (item['email'] or item['remote_addr']))
|
||||||
|
self.cache.delete('text', str(item['id']))
|
||||||
|
|
||||||
with self.isso.lock:
|
with self.isso.lock:
|
||||||
rv = self.comments.delete(id)
|
rv = self.comments.delete(id)
|
||||||
@ -369,6 +371,7 @@ class API(object):
|
|||||||
args['parent'] = None
|
args['parent'] = None
|
||||||
root_id = None
|
root_id = None
|
||||||
|
|
||||||
|
# FIXME inverse logic
|
||||||
plain = request.args.get('plain', '0') == '0'
|
plain = request.args.get('plain', '0') == '0'
|
||||||
|
|
||||||
reply_counts = self.comments.reply_count(uri, after=args['after'])
|
reply_counts = self.comments.reply_count(uri, after=args['after'])
|
||||||
@ -437,7 +440,13 @@ class API(object):
|
|||||||
|
|
||||||
if plain:
|
if plain:
|
||||||
for item in fetched_list:
|
for item in fetched_list:
|
||||||
item['text'] = self.isso.render(item['text'])
|
key = str(item['id'])
|
||||||
|
val = self.cache.get('text', key)
|
||||||
|
if val is None:
|
||||||
|
val = self.isso.render(item['text'])
|
||||||
|
self.cache.set('text', key, val)
|
||||||
|
|
||||||
|
item['text'] = val
|
||||||
|
|
||||||
return fetched_list
|
return fetched_list
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ http = :8080
|
|||||||
master = true
|
master = true
|
||||||
processes = 4
|
processes = 4
|
||||||
cache2 = name=hash,items=10240,blocksize=32
|
cache2 = name=hash,items=10240,blocksize=32
|
||||||
|
cache2 = name=text,items=1024
|
||||||
spooler = %d/mail
|
spooler = %d/mail
|
||||||
module = isso.run
|
module = isso.run
|
||||||
virtualenv = %d
|
virtualenv = %d
|
||||||
|
Loading…
Reference in New Issue
Block a user