| 121 | print(f'{msg}') |
| 122 | |
| 123 | def getCache(self, key): |
| 124 | value = self.fetch(f'http://127.0.0.1:{Proxy.getPort()}/cache?do=get&key={key}', timeout=5).text |
| 125 | if len(value) > 0: |
| 126 | if value.startswith('{') and value.endswith('}') or value.startswith('[') and value.endswith(']'): |
| 127 | value = json.loads(value) |
| 128 | if type(value) == dict: |
| 129 | if not 'expiresAt' in value or value['expiresAt'] >= int(time.time()): |
| 130 | return value |
| 131 | else: |
| 132 | self.delCache(key) |
| 133 | return None |
| 134 | return value |
| 135 | else: |
| 136 | return None |
| 137 | |
| 138 | def setCache(self, key, value): |
| 139 | if type(value) in [int, float]: |