예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)