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

Unified Diff: app.py

Issue 11934003: Put latest_rev data in datastore instead of memcache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/chromium-build
Patch Set: Adding quick efficiency increase to this change. Created 7 years, 11 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: app.py
diff --git a/app.py b/app.py
index 0a5519163f8a4bad86f0c17fd8b9c51b535e4fee..fa5050000460638e0af8e4a276acb8eb6ad058c9 100644
--- a/app.py
+++ b/app.py
@@ -212,9 +212,9 @@ def get_and_cache_rowdata(localpath):
Here we assume localpath is already unquoted.
"""
row_data = get_data_from_cache(localpath)
- if row_data:
+ if row_data and type(row_data) == type({}):
return row_data
- row = Row.all().filter('localpath =', localpath).get()
+ row = Row.get_by_key_name(localpath)
if not row:
logging.error('get_and_cache_rowdata(\'%s\'): no matching localpath in '
'datastore' % localpath)
@@ -254,11 +254,21 @@ def save_row(row_data, localpath):
# pylint: disable=E1103
row.put()
db.run_in_transaction(tx_row, row_key)
- prev_rev = memcache.get(key='latest_rev')
- if (rev_number > prev_rev):
- memcache.set(key='latest_rev', value=rev_number)
put_data_into_cache(localpath, row_data)
logging.info('Saved and cached row with localpath %s' % localpath)
+ # Update latest_rev in datastore & cache, or create it if it doesn't exist.
+ prev_rev = get_and_cache_rowdata('latest_rev')
+ if not prev_rev or rev_number > prev_rev['rev_number']:
+ latest_rev_row = {
+ 'rev_number': rev_number,
+ 'fetch_timestamp': datetime.datetime.now(),
+ 'rev': None,
+ 'name': None,
+ 'status': None,
+ 'comment': None,
+ 'details': None,
+ }
+ save_row(latest_rev_row, 'latest_rev')
##########
@@ -388,7 +398,7 @@ def console_merger(localpath, remoteurl, page_data,
surroundings = get_and_cache_pagedata('surroundings')
merged_page = BeautifulSoup(surroundings['content'])
merged_tag = merged_page.find('table', 'ConsoleData')
- latest_rev = int(memcache.get(key='latest_rev'))
+ latest_rev = int(get_and_cache_rowdata('latest_rev')['rev_number'])
if not latest_rev:
logging.error('console_merger(\'%s\', \'%s\', \'%s\'): cannot get latest '
'revision number.' % (
« 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