MCPcopy
hub / github.com/saltstack/salt / sweep

Method sweep

salt/utils/cache.py:267–279  ·  view source on GitHub ↗

Sweep the cache and remove the outdated or least frequently used entries

(self)

Source from the content-addressed store, hash-verified

265 self.cache.clear()
266
267 def sweep(self):
268 """
269 Sweep the cache and remove the outdated or least frequently
270 used entries
271 """
272 if self.max_age < time.time() - self.timestamp:
273 self.clear()
274 self.timestamp = time.time()
275 else:
276 patterns = list(self.cache.values())
277 patterns.sort(key=lambda x: x[0])
278 for idx in range(self.clear_size):
279 del self.cache[patterns[idx][2]]
280
281 def get(self, pattern):
282 """

Callers 1

getMethod · 0.95

Calls 4

clearMethod · 0.95
timeMethod · 0.80
listFunction · 0.50
valuesMethod · 0.45

Tested by

no test coverage detected