示例#1
0
 def gen_date_key(date, user_id):
     # be careful: the time format string below is designed to have 12 places to allow comparison of keys in order
     # this will run out in the year 33679 - assuming the year 2038 problem is fixed :)
     # to those that are maintaining the code in 33679CE: sorry! but i'm sure you'll be able to fix it and upgrade properly.
     # Say high to my descendants for me too!
     count = increment('activity_%s' % user_id)
     return '%s||%s||%s' % (date.strftime('%012s'), user_id, count)
示例#2
0
 def gen_date_key(date,user_id):
     # be careful: the time format string below is designed to have 12 places to allow comparison of keys in order
     # this will run out in the year 33679 - assuming the year 2038 problem is fixed :)
     # to those that are maintaining the code in 33679CE: sorry! but i'm sure you'll be able to fix it and upgrade properly. 
     # Say high to my descendants for me too!
     count = increment('activity_%s'%user_id)
     return '%s||%s||%s' % (date.strftime('%012s'),user_id,count)
示例#3
0
 def make_key_name(target,count=None):
     try:
         target_key = target.key()
     except AttributeError: # a key was passed into target, hopefully
         target_key = target
     target_id = target_key.id()
     if not count:
         count = increment('Comment_%s'%target_id)
     return '%s||%012d' % (target_id,count)
示例#4
0
 def gen_date_key(date):
     """ generates a key which can be used to sort entries in date order
         uses sharded counters to allow multiple actions in the same second
     
         be careful: the time format string below is designed to have 12 places to allow comparison of keys in order
         this will run out in the year 33679 - assuming the year 2038 problem is fixed :)
         to those that are maintaining the code in 33679CE: sorry! but i'm sure you'll be able to fix it and upgrade properly. 
         Say high to my descendants for me too!
     """
     seconds = date.strftime('%012s')
     count = increment('action_%s'%seconds)
     return '%s|%s' % (seconds,count)
示例#5
0
 def refill_impressions(self, impressions):
     shardedcounter.increment(str(self.key()), impressions)
示例#6
0
 def increment_pending_score(self):
     shardedcounter.increment('pending_score', 1)
示例#7
0
 def increment_product_score(self):
     shardedcounter.increment('product_score', 1)
示例#8
0
 def increment_maker_score(self):
     shardedcounter.increment('maker_score', 1)