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

Method clearCache

graphs/data/base/graph.py:116–155  ·  view source on GitHub ↗
(self, reason, extraData=None)

Source from the content-addressed store, hash-verified

114 return y
115
116 def clearCache(self, reason, extraData=None):
117 caches = (self._plotCache, self._pointCache)
118 plotKeysToClear = set()
119 # If fit changed - clear plots which concern this fit
120 if reason in (GraphCacheCleanupReason.fitChanged, GraphCacheCleanupReason.fitRemoved):
121 for cache in caches:
122 for cacheKey in cache:
123 cacheFitID, cacheTgtType, cacheTgtID = cacheKey
124 if extraData == cacheFitID:
125 plotKeysToClear.add(cacheKey)
126 elif cacheTgtType == 'fit' and extraData == cacheTgtID:
127 plotKeysToClear.add(cacheKey)
128 # Same for profile
129 elif reason in (GraphCacheCleanupReason.profileChanged, GraphCacheCleanupReason.profileRemoved):
130 for cache in caches:
131 for cacheKey in cache:
132 cacheFitID, cacheTgtType, cacheTgtID = cacheKey
133 if cacheTgtType == 'profile' and extraData == cacheTgtID:
134 plotKeysToClear.add(cacheKey)
135 # Target fit resist mode changed
136 elif reason == GraphCacheCleanupReason.resistModeChanged:
137 for cache in caches:
138 for cacheKey in cache:
139 cacheFitID, cacheTgtType, cacheTgtID = cacheKey
140 if cacheTgtType == 'fit' and extraData == cacheTgtID:
141 plotKeysToClear.add(cacheKey)
142 # Wipe out whole plot cache otherwise
143 else:
144 for cache in caches:
145 for cacheKey in cache:
146 plotKeysToClear.add(cacheKey)
147 # Do actual cleanup
148 for cache in caches:
149 for cacheKey in plotKeysToClear:
150 try:
151 del cache[cacheKey]
152 except KeyError:
153 pass
154 # Process any internal caches graphs might have
155 self._clearInternalCache(reason, extraData)
156
157 def _makeCacheKey(self, src, tgt):
158 if tgt is not None and tgt.isFit:

Callers

nothing calls this directly

Calls 1

_clearInternalCacheMethod · 0.95

Tested by

no test coverage detected