community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject svn commit: r1864058 - /comdev/reporter.apache.org/trunk/site/getjson.py
Date Wed, 31 Jul 2019 13:14:09 GMT
Author: humbedooh
Date: Wed Jul 31 13:14:09 2019
New Revision: 1864058

URL: http://svn.apache.org/viewvc?rev=1864058&view=rev
Log:
Deploy primitive caching, 2h hold.

Modified:
    comdev/reporter.apache.org/trunk/site/getjson.py

Modified: comdev/reporter.apache.org/trunk/site/getjson.py
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/getjson.py?rev=1864058&r1=1864057&r2=1864058&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/getjson.py (original)
+++ comdev/reporter.apache.org/trunk/site/getjson.py Wed Jul 31 13:14:09 2019
@@ -240,6 +240,15 @@ if re.match(r"^[-a-zA-Z0-9_.]+$", user):
     if oproject and len(oproject) > 0 and isMember:
         groups = [oproject]
     groups.sort() # so tabs appear in order
+    
+    # Try cache first?
+    wanted_file = "/tmp/%s.json" % "-".join(groups)
+    if (os.path.exists(wanted_file) and os.path.getmtime(wanted_file) > (time.time() -
7200)):
+        dump = open(wanted_file, "r").read()
+        sys.stdout.write("Content-Type: application/json\r\nContent-Length: %u\r\n\r\n" %
(len(dump)))
+        sys.stdout.write(dump)
+        sys.exit(0)
+    
     mlstats = {}
     ml = readJson(RAOHOME+"data/mailinglists.json")
     for entry in ml: # e.g. abdera.apache.org-commits, ws.apache.org-dev
@@ -371,6 +380,11 @@ if re.match(r"^[-a-zA-Z0-9_.]+$", user):
     dump = json.dumps(output, indent=1, sort_keys=True).replace('\n', '\r\n')
     sys.stdout.write("Content-Type: application/json\r\nContent-Length: %u\r\n\r\n" % (len(dump)))
     sys.stdout.write(dump)
+    
+    # Write dump to cache
+    with open(wanted_file, "w") as f:
+        f.write(dump)
+        f.close()
 else:
     sys.stdout.write("Content-Type: text/html\r\n\r\n")
     sys.stdout.write("Unknown or invalid user id presented")



Mime
View raw message