def rm(cls, user_id, id, cid): key = R_STAR_BY_USER_ID_CID % (user_id, 0) if redis.zrank(key, id) is not None: with redis.pipeline() as p: p.hincrby(R_STAR_COUNT, user_id, -1) p.hincrby(R_STAR_COUNT, id, -1) p.zrem(key, id) p.zrem(R_STAR_BY_USER_ID_CID % (user_id, cid), id) p.zrem(R_STAR_BY_ID % id, user_id) p.execute()
def rm(cls, user_id, id, cid): key = R_STAR_BY_USER_ID_CID % (user_id, 0) if redis.zrank(key, id) is not None: with redis.pipeline() as p: p.hincrby(R_STAR_COUNT, user_id, -1) p.hincrby(R_STAR_COUNT, id, -1) p.zrem(key, id) p.zrem(R_STAR_BY_USER_ID_CID%(user_id, cid), id) p.zrem(R_STAR_BY_ID % id, user_id) p.execute()
def new(cls, user_id, id, cid): key = R_STAR_BY_USER_ID_CID % (user_id, 0) if redis.zrank(key, id) is None: _now = int(time()) with redis.pipeline() as p: p.hincrby(R_STAR_COUNT, user_id) p.hincrby(R_STAR_COUNT, id) p.zadd(key, _now, id) p.zadd(R_STAR_BY_USER_ID_CID % (user_id, cid), _now, id) p.zadd(R_STAR_BY_ID % id, time(), user_id) p.execute()
def new(cls, user_id, id, cid): key = R_STAR_BY_USER_ID_CID % (user_id, 0) if redis.zrank(key, id) is None: _now = int(time()) with redis.pipeline() as p: p.hincrby(R_STAR_COUNT, user_id) p.hincrby(R_STAR_COUNT, id) p.zadd(key, _now, id) p.zadd(R_STAR_BY_USER_ID_CID%(user_id, cid), _now, id) p.zadd(R_STAR_BY_ID % id, time(), user_id) p.execute()