Пример #1
0
def flag_topic(tid):
    key = 'flag:%d:t-%d' % (current_user.id, tid)
    if cache.get(key):
        return '', 204
    cache.inc(key)
    TopicStat(tid).flag()
    return '', 204
Пример #2
0
def flag_topic(tid):
    key = 'flag:%d:t-%d' % (current_user.id, tid)
    if cache.get(key):
        return '', 204
    cache.inc(key)
    TopicStat(tid).flag()
    return '', 204
Пример #3
0
def flag_topic_comment(tid, cid):
    key = 'flag:%d:c-%d' % (current_user.id, cid)
    if cache.get(key):
        return '', 204
    comment = get_comment_or_404(tid, cid)
    # here is a concurrency bug, but it doesn't matter
    comment.flag_count += 1
    with db.auto_commit():
        db.session.add(comment)
    # one person, one flag
    cache.inc(key)
    return '', 204
Пример #4
0
def flag_topic_comment(tid, cid):
    key = 'flag:%d:c-%d' % (current_user.id, cid)
    if cache.get(key):
        return '', 204
    comment = get_comment_or_404(tid, cid)
    # here is a concurrency bug, but it doesn't matter
    comment.flag_count += 1
    with db.auto_commit():
        db.session.add(comment)
    # one person, one flag
    cache.inc(key)
    return '', 204
Пример #5
0
 def receive_after_insert(mapper, conn, target):
     cache.inc(target.generate_cache_prefix('count'))