Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1038)

Unified Diff: Tools/GardeningServer/alerts.py

Issue 469983002: Compress alerts with zlib level 1 to fit in sheriff-o-matic's memcache. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Tools/GardeningServer/alerts.py
diff --git a/Tools/GardeningServer/alerts.py b/Tools/GardeningServer/alerts.py
index 136eafba9f8d59b37509d21432f732217334f02f..8679c118b65dddf655ceb1c8f5e8c7cc6d3c00a6 100644
--- a/Tools/GardeningServer/alerts.py
+++ b/Tools/GardeningServer/alerts.py
@@ -6,6 +6,7 @@ import calendar
import datetime
import json
import webapp2
+import zlib
from google.appengine.api import memcache
@@ -24,10 +25,11 @@ class AlertsHandler(webapp2.RequestHandler):
def get(self):
self.response.headers.add_header('Access-Control-Allow-Origin', '*')
self.response.headers['Content-Type'] = 'application/json'
- alerts = memcache.get(AlertsHandler.MEMCACHE_ALERTS_KEY)
- if not alerts:
+ compressed = memcache.get(AlertsHandler.MEMCACHE_ALERTS_KEY)
+ if not compressed:
return
- self.response.write(json.dumps(alerts, cls=DateTimeEncoder, indent=1))
+ uncompressed = zlib.decompress(compressed)
+ self.response.write(uncompressed)
def post(self):
try:
@@ -39,7 +41,10 @@ class AlertsHandler(webapp2.RequestHandler):
'date': datetime.datetime.utcnow(),
'alerts': alerts['alerts']
})
- memcache.set(AlertsHandler.MEMCACHE_ALERTS_KEY, alerts)
+ uncompressed = json.dumps(alerts, cls=DateTimeEncoder, indent=1)
+ compression_level = 1
+ compressed = zlib.compress(uncompressed, compression_level)
ojan 2014/08/14 01:03:51 Nit: can you just do the following? compressed = z
+ memcache.set(AlertsHandler.MEMCACHE_ALERTS_KEY, compressed)
app = webapp2.WSGIApplication([
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698