Пример #1
0
        def get_group_value(group):
            d = self.redis_client.hgetall(
                    redis_keys.get_session_value_key(account_id, campaign_id, group))

            try:
                count = d['count']

                if 'value' in d:
                    if count:
                        return float(d['value']) / float(count)
                    else:
                        return None
                else:
                    return 0
            except KeyError:
                return None
Пример #2
0
 def update_session_value(self, account, cid, group, value):
     key = keys.get_session_value_key(account, cid, group)
     redis.hincrby(key, 'count', 1)
     redis.hincrby(key, 'value', int(float(value)))