Split local cache functions to cache.py