Esempio n. 1
0
    def _add_to_ev(self, data, subject=None):
        gkey = mkname("events")
        pkey = mkname("events", user_id(subject))

        pipe = self.client.pipeline()
        pipe.lpush(gkey, data)
        pipe.lpush(pkey, data)
        pipe.execute(callback=lambda x: None)
Esempio n. 2
0
    def _add_to_ev(self, data, subject=None):
        gkey = mkname("events")
        pkey = mkname("events", user_id(subject))

        pipe = self.client.pipeline()
        pipe.lpush(gkey, data)
        pipe.lpush(pkey, data)
        pipe.execute(callback=lambda x: None)
Esempio n. 3
0
 def _counter_get(self, user, counter, callback):
     def parse(res):
         if isinstance(res, basestring):
             try:
                 callback(int(res))
             except ValueError:
                 callback(float(res))
         elif res is None:
             callback(0)
         else:
             callback(res)
     hash_name = mkname("counter", user_id(user))
     self.client.hget(hash_name, counter, callback=parse)
Esempio n. 4
0
    def _counter_get(self, user, counter, callback):
        hash_name = mkname("counter", user_id(user))

        res = self.client.hget(hash_name, counter)

        if isinstance(res, string_types):
            try:
                callback(int(res))
            except ValueError:
                callback(float(res))
        elif res is None:
            callback(0)
        else:
            callback(res)
Esempio n. 5
0
    def _counter_get(self, user, counter, callback):
        hash_name = mkname("counter", user_id(user))

        res = self.client.hget(hash_name, counter)

        if isinstance(res, string_types):
            try:
                callback(int(res))
            except ValueError:
                callback(float(res))
        elif res is None:
            callback(0)
        else:
            callback(res)
Esempio n. 6
0
    def _counter_get(self, user, counter, callback):
        def parse(res):
            if isinstance(res, basestring):
                try:
                    callback(int(res))
                except ValueError:
                    callback(float(res))
            elif res is None:
                callback(0)
            else:
                callback(res)

        hash_name = mkname("counter", user_id(user))
        self.client.hget(hash_name, counter, callback=parse)
Esempio n. 7
0
    def _counter_add(self, user, counter, amount, callback):
        hash_name = mkname("counter", user_id(user))

        res = self.client.hincrby(hash_name, counter, amount)

        callback(res)
Esempio n. 8
0
 def add_badge(self, user, badge, callback):
     key = mkname("badges", user_id(user))
     success = self.client.sadd(key, badge.badge_id) == 1
     callback(success)
Esempio n. 9
0
    def add_badge(self, user, badge, callback):
        def parse(n):
            callback(n == 1)

        key = mkname("badges", user_id(user))
        self.client.sadd(key, badge.badge_id, callback=parse)
Esempio n. 10
0
    def _counter_add(self, user, counter, amount, callback):
        hash_name = mkname("counter", user_id(user))

        res = self.client.hincrby(hash_name, counter, amount)

        callback(res)
Esempio n. 11
0
 def add_badge(self, user, badge, callback):
     key = mkname("badges", user_id(user))
     success = self.client.sadd(key, badge.badge_id) == 1
     callback(success)
Esempio n. 12
0
    def add_badge(self, user, badge, callback):
        def parse(n):
            callback(n == 1)

        key = mkname("badges", user_id(user))
        self.client.sadd(key, badge.badge_id, callback=parse)