Example #1
0
 def _delete_expired_key(self, key):
     '''
     @summary: 
         指定されたパスのファイルが期限切れの場合、削除します
     '''
     path = build_path(self.cache_dir, key)
     data = load(path)
     if is_expired(data.expiration_date):
         # 古いキャッシュの際は削除する
         self._delete_file(path)
Example #2
0
 def sync(self):
     '''
     @summary: 
         現在保持しているメモリキャッシュをファイルキャッシュで更新します
     '''
     try:
         self.cache.update(load(self.cache_file))
     except Exception:
         # pickle error
         raise
Example #3
0
 def _fetch_cache_file(self, key):
     '''
     @summary: 
         指定したキーでファイル上からデータを取得します
     '''
     try:
         path = build_path(self.cache_dir, key)
         data = load(path)
         if is_expired(data.expiration_date):
             raise ExpiredError("ExpiredError")
     except IOError:
         # if not exists file
         raise KeyError(key)
     except OSError:
         # Not Found key-cachefile
         raise KeyError(key)
     except ValueError,err:
         raise ValueError("Cache File '%s' style is wrong." % path)