Fixes #3387 : add a cache in the RuleGrid to prevent duplicate queries