Find why the second call can return a stale price.
Python
from functools import lru_cache
catalog = {"paper": 5}
@lru_cache(maxsize=32)
def price(sku):
return catalog[sku]
print(price("paper"))
catalog["paper"] = 6
print(price("paper"))
from functools import lru_cache
catalog = {"paper": 5}
@lru_cache(maxsize=32)
def price(sku):
return catalog[sku]
print(price("paper"))
catalog["paper"] = 6
print(price("paper"))