timeline.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:isthislegit 作者: duo-labs 项目源码 文件源码
def update(cls, date, domain, new, old=None):
        """
        Updates a timeline record for a given day. It also attempts
        to update the data (if any) in memcached to prevent a full cache
        reload.
        """
        record = cls.query(cls.date == date).get()
        if not record:
            print 'no record found.'
            record = StatusTimeline(domain=domain, date=date, statuses={})
            record.put()

        if old:
            print 'Removing 1 from {}'.format(old)
            record.statuses[old] -= 1
        print 'Updating entry on {} to {} with new value {}'.format(
            date, new, record.statuses[new])
        record.statuses[new] += 1
        record.put()

        # Temporary update to memcached since the data is eventually
        # consistent
        cls._update_memcached(domain, time=5)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号