Commit fce66140 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: Fill cache for pre-calculated news_dict too

    This ensure that when users access the site, the information is likely to be cached already.
parent d3dfa4a3
......@@ -108,12 +108,13 @@ class SlapOSComputeNodeMixin(object):
def _fillComputeNodeInformationCache(self, user):
key = '%s_%s' % (self.getReference(), user)
refresh_etag = self._calculateRefreshEtag()
try:
computer_dict = self._getCacheComputeNodeInformation(user)
self._getCachePlugin().set(key, DEFAULT_CACHE_SCOPE,
dict (
time=time.time(),
refresh_etag=self._calculateRefreshEtag(),
refresh_etag=refresh_etag,
data=computer_dict,
# Store the XML while SlapTool Still used
data_xml=self.getPortalObject().portal_slap._getSlapComputeNodeXMLFromDict(computer_dict)
......@@ -130,6 +131,10 @@ class SlapOSComputeNodeMixin(object):
# called on site
pass
# Also update cache for News Dict, so it speed up access of this UI.
key = '%s_partition_news' % self.getReference()
self._getCachedComputePartitionNewsDict(key, refresh_etag)
def _calculateRefreshEtag(self):
# check max indexation timestamp
# it is unlikely to get an empty catalog
......@@ -345,7 +350,7 @@ class SlapOSComputeNodeMixin(object):
if (refresh_etag != cached_etag):
return self._getCachedComputePartitionNewsDict(key, refresh_etag)
else:
return cached_dict.get('data')
return cached_dict.get('data')
return self._getCachedComputePartitionNewsDict(key, refresh_etag)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment