Fix infinite recursion bug in cache.

- Fix an infinite recursion bug in the cache.
- Adjust indentation in list comprehension.