In #42413 , cache invalidation logic of topic is redesigned.
However, Discourse.cache.keys("page_not_found_topics:*").each { |key| Discourse.cache.redis.del(key) } will traverse all of the redis keys, causing performance issues, and may timeout if there are large amount of keys.
For a site with a large Redis DB, users may encounter 500 error when they move a topic to a restricted category.
This commit restrict the traverse scope to Discourse.cache.normalize_key("page_not_found_topics:#{locale}"), which is far smaller than the whole redis, also add a test to avoid the execution of scan_each.