Use lru_cache, fallback to deprecated memoize