Beispiel #1
0
 def __parse_life_span_string():
     try:
         return long(life_span_string)
     except ValueError:
         try:
             (d, h, m, s) = TIME_RE.match(life_span_string).groups()
             # time conversions in seconds
             times = [(s, 1), (m, 60), (h, 3600), (d, 86400)]
             # sum the converted times
             # if not specified (None) use 0
             return sum(long(t[0] or 0) * t[1] for t in times)
         except:
             print('error parsing life_span_string {0}'.format(
                 life_span_string))
             traceback.print_exc()
             # default 30 minutes in seconds
             return 1800
Beispiel #2
0
 def __parse_life_span_string():
     try:
         return long(life_span_string)
     except ValueError:
         try:
             (d, h, m, s) = TIME_RE.match(life_span_string).groups()
             # time conversions in seconds
             times = [(s, 1), (m, 60), (h, 3600), (d, 86400)]
             # sum the converted times
             # if not specified (None) use 0
             return sum(long(t[0] or 0) * t[1] for t in times)
         except:
             print('error parsing life_span_string {0}'.format(
                 life_span_string))
             traceback.print_exc()
             # default 30 minutes in seconds
             return 1800
Beispiel #3
0
    def is_up_to_date(self, key, timestamp):
        if timestamp is None:
            return False

        cache_life_span = LocalCache._get_cache_life_span()

        current_time = long(time.time())
        if timestamp + cache_life_span < current_time:
            return False

        return True
Beispiel #4
0
    def is_up_to_date(self, key, timestamp):
        if timestamp is None:
            return False

        cache_life_span = LocalCache._get_cache_life_span()

        current_time = long(time.time())
        if timestamp + cache_life_span < current_time:
            return False

        return True
Beispiel #5
0
 def validate_on_set(self, key, obj):
     if not self.has(self._CACHE_TIMESTAMP):
         Cache.set(self, self._CACHE_TIMESTAMP, long(time.time()))
Beispiel #6
0
 def validate_on_set(self, key, obj):
     if not self.has(self._CACHE_TIMESTAMP):
         Cache.set(self, self._CACHE_TIMESTAMP, long(time.time()))