Exemple #1
0
 def aget_all_rewards(self, user):
     all_rewards = yield call(self._aclient.hvals, user.id)
     raise gen.Return(
         sum([sum(safe_eval(reward)) for reward in all_rewards]))
Exemple #2
0
 def adel_reward(self, user, *args):
     yield call(self._aclient.hdel, user.id, self._key_func(*args))
Exemple #3
0
    def aexist_reward(self, user, *args):
        exist = yield call(self._aclient.hexists, user.id,
                           self._key_func(*args))

        raise gen.Return(exist)
Exemple #4
0
 def aset_reward(self, user, reward, *args):
     raise gen.Return((yield call(self._aclient.hset, user.id,
                                  self._key_func(*args),
                                  _RewardUtils.split_reward(user, reward))))
Exemple #5
0
    def aget_reward(self, user, *args):
        reward_list = yield call(self._aclient.hget, user.id,
                                 self._key_func(*args))

        raise gen.Return(safe_eval(reward_list))
Exemple #6
0
 def _ascan_task(self, queue=None):
     result = yield call(self._aclient.zscan, queue)
     raise gen.Return(result)
Exemple #7
0
 def _adel_task(self, key, queue=None):
     yield call(self._aclient.zrem, queue, key)
Exemple #8
0
 def _aadd_task(self, key, value, queue=None):
     yield call(self._aclient.zadd, queue, key, value)
Exemple #9
0
    def aget_all_reward_by(self, user, bright_point=False):
        index = 0 if bright_point else 1
        all_rewards = yield call(self._aclient.hvals, user.id)

        raise gen.Return(
            sum([sum(safe_eval(reward)[index]) for reward in all_rewards]))
Exemple #10
0
    def listen(self):
        yield call(self._client.subscribe, REDIS_CHANNEL)

        self._client.listen(self.on_message)