move the cache function (from prime_with_cache) to a separate class