def _most_recent_property(
cls, name, property_name, default_value=None, serialize=lambda x: x, deserialize=lambda x: x, ttl=120):
cache_key = CrashReport.recent_crash_property_key(name, property_name)
most_recent_value = memcache.get(cache_key)
if most_recent_value is None:
most_recent = 0
most_recent_value = default_value
q = CrashReport.all()
q.filter('name = ', name)
for entity in q.run():
in_millis = to_milliseconds(entity.date_time)
if most_recent <= in_millis:
most_recent = in_millis
most_recent_value = serialize(entity.__getattribute__(property_name))
memcache.set(cache_key, most_recent_value, ttl)
to_return = deserialize(most_recent_value)
return to_return
评论列表
文章目录