MCPcopy Create free account
hub / github.com/FongMi/TV / getCache

Method getCache

chaquo/src/main/python/base/spider.py:123–136  ·  view source on GitHub ↗
(self, key)

Source from the content-addressed store, hash-verified

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]:

Callers

nothing calls this directly

Calls 4

fetchMethod · 0.95
delCacheMethod · 0.95
timeMethod · 0.80
getPortMethod · 0.45

Tested by

no test coverage detected