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

Method get

salt/utils/cache.py:281–295  ·  view source on GitHub ↗

Get a compiled regular expression object based on pattern and cache it when it is not in the cache already

(self, pattern)

Source from the content-addressed store, hash-verified

279 del self.cache[patterns[idx][2]]
280
281 def get(self, pattern):
282 """
283 Get a compiled regular expression object based on pattern and
284 cache it when it is not in the cache already
285 """
286 try:
287 self.cache[pattern][0] += 1
288 return self.cache[pattern][1]
289 except KeyError:
290 pass
291 if len(self.cache) > self.size:
292 self.sweep()
293 regex = re.compile(f"{self.prepend}{pattern}{self.append}")
294 self.cache[pattern] = [1, regex, pattern, time.time()]
295 return regex
296
297
298class ContextCache:

Callers 15

__init__Method · 0.45
_install_indv_pkgMethod · 0.45
_resolve_depsMethod · 0.45
_traverse_reposMethod · 0.45
_query_httpMethod · 0.45
_verboseMethod · 0.45
_renderMethod · 0.45
register_pkgFunction · 0.45
check_existingFunction · 0.45
install_fileFunction · 0.45
__init__Method · 0.45

Calls 2

sweepMethod · 0.95
timeMethod · 0.80

Tested by 9

pingFunction · 0.36
random_hashFunction · 0.36
metasyntacticFunction · 0.36
succeed_without_changesFunction · 0.36
fail_without_changesFunction · 0.36
succeed_with_changesFunction · 0.36
fail_with_changesFunction · 0.36
mod_watchFunction · 0.36