Пример #1
0
def mark_online(user_id):
    now = int(time.time())
    expires = now + (app.config['ONLINE_LAST_MINUTES'] * 60) + 10
    all_users_key = 'online-users/%d' % (now // 60)
    user_key = 'user-activity/%s' % user_id
    p = redis.pipeline()
    p.sadd(all_users_key, user_id)
    p.set(user_key, now)
    p.expireat(all_users_key, expires)
    p.expireat(user_key, expires)
    p.execute()
Пример #2
0
def mark_menu(user_id, menu_marker):
    try:
        tmp = int(menu_marker)
    except Exception:
        menu_marker = None
        pass
    now = int(time.time())
    expires = now + (app.config['ONLINE_LAST_MINUTES'] * 60) + 10
    user_key = 'user-menu/%s' % user_id
    p = redis.pipeline()
    p.set(user_key, menu_marker)
    p.expireat(user_key, expires)
    p.execute()