MCPcopy Create free account
hub / github.com/pyfa-org/Pyfa / setCache

Function setCache

eos/db/saveddata/queries.py:57–71  ·  view source on GitHub ↗
(cacheKey, args, kwargs)

Source from the content-addressed store, hash-verified

55 localQueryCache = typeQueryCache[function] = {}
56
57 def setCache(cacheKey, args, kwargs):
58 items = function(*args, **kwargs)
59 IDs = set()
60 localQueryCache[cacheKey] = (isinstance(items, list), IDs)
61 stuff = items if isinstance(items, list) else (items,)
62 for item in stuff:
63 ID = getattr(item, "ID", None)
64 if ID is None:
65 # Some uncachable data, don't cache this query
66 del localQueryCache[cacheKey]
67 break
68 localItemCache[ID] = item
69 IDs.add(ID)
70
71 return items
72
73 def checkAndReturn(*args, **kwargs):
74 useCache = kwargs.pop("useCache", True)

Callers 1

checkAndReturnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected