Update cache.py

Why iteration the whole dictionary entirely when the desired item is found, it is better to terminate the iteration by break