MCPcopy Create free account
hub / github.com/NCAR/wrf-python / _shrink_cache

Function _shrink_cache

src/wrf/cache.py:12–34  ·  view source on GitHub ↗

Shrink the cache if applicable. This only applies if a user has modified the cache size, otherwise it just returns. Returns: None

()

Source from the content-addressed store, hash-verified

10
11
12def _shrink_cache():
13 """Shrink the cache if applicable.
14
15 This only applies if a user has modified the cache size, otherwise it
16 just returns.
17
18 Returns:
19
20 None
21
22 """
23 global _local_storage
24
25 try:
26 cache = _local_storage.cache
27 except AttributeError:
28 return
29
30 diff = len(cache) - get_cache_size()
31
32 if diff > 0:
33 for _ in py3range(diff):
34 cache.popitem(last=False)
35
36
37def cache_item(key, product, value):

Callers 3

cache_itemFunction · 0.85
get_cached_itemFunction · 0.85
_get_cacheFunction · 0.85

Calls 2

get_cache_sizeFunction · 0.85
py3rangeFunction · 0.85

Tested by

no test coverage detected