public function createCachedConditionGenerator($conditionGenerator, $ttl = null): ConditionGenerator
    {
        if (null === $this->cacheDriver) {
            return $conditionGenerator;
        }

        if ($conditionGenerator instanceof DqlConditionGenerator) {
            return new CachedDqlConditionGenerator($conditionGenerator, $this->cacheDriver, $ttl);
        } elseif ($conditionGenerator instanceof NativeQueryConditionGenerator) {
            return new CachedNativeQueryConditionGenerator($conditionGenerator, $this->cacheDriver, $ttl);
        }

        throw new \InvalidArgumentException(
            sprintf('ConditionGenerator "%s" is not supported by the DoctrineOrmFactory.', \get_class($conditionGenerator))
        );
    }