示例#1
0
 def reset_pattern(self, pattern_key):
     #similar to above, but can pass pattern as arg instead
     try:
         cache_key = COUNTER_CACHE_KEY % pattern_key
         for object in Count.getall(cache_key):
             object.delete()
         freq_cache_key = COUNTER_FREQ_CACHE_KEY % pattern_key
         for object in  Count.getall(freq_cache_key):
             object.delete()
         return True
     except :
         # Handle Redis failures gracefully
         return False
示例#2
0
 def get_frequencies(self, key):
     try:
         freq_cache_key = COUNTER_FREQ_CACHE_KEY % key
         return dict((int(o.field), int(o.count)) for o in Count.getall(freq_cache_key) if int(o.count) > 0)
     except :
         # Handle Redis failures gracefully
         return tuple()