Limit memoize cache size to avoid effective memory leak
Use lru-cache gem for bounded space memoization