I am testing lru_cache for the first time. A simple request. The code works fine but multiple runs of the code do not change cache_info()
import requests
from functools import lru_cache
url = 'http://www.python.org/dev/peps/pep-'
my_list = [290, 308, 320, 8, 218, 320, 279, 289, 320]
@lru_cache(maxsize=20, typed=False)
def fetch_data():
for item in my_list:
data = requests.get(url+str(item))
print(len(data.text))
if __name__ == "__main__":
fetch_data()
print(fetch_data.cache_info())
Results:
53159
41324
21598
118304
20618
21598
20153
30451
21598
**CacheInfo(hits=0, misses=1, maxsize=20, currsize=1)**
➜ ~ /usr/local/bin/python3 pythonProject/main_6.py
53159
41324
21598
118304
20618
21598
20153
30451
21598
**CacheInfo(hits=0, misses=1, maxsize=20, currsize=1)**
With the subsequent runs, I was expecting the hits/misses/currsize parameters to change?