Cannot clear APCu Cache from Console, it’s shared in the Webserver memory and not accessible from the CLI

I’m trying to clear doctrine cache after updating entities, so that there won’t be errors like this after adding new property:

Uncaught Error: Typed property ProjectEntitiesEntity::$property must not be accessed before initialization in ...

php cli-config.php orm:clear-cache:metadata and php cli-config.php orm:clear-cache:result works fine but when I’m trying to execute php cli-config.php orm:clear-cache:query I get Error:

In QueryCommand.php line 43:
                                                                                                              
  Cannot clear APCu Cache from Console, it's shared in the Webserver memory and not accessible from the CLI.

If I disable APCu for CLI in php.ini like this:

apc.enable_cli=0

then orm:clear-cache:query results in:

In MemcachedAdapter.php line 300:
                                                     
  MemcachedAdapter client error: connection failure

as Doctrine defaults to MemcachedAdapter if APCu is unavailable.

When creating EntityManager with isDevMode set to true, it works fine (no errors occur) but I’m not convinced it’s a valid solution.

new EntityManager(
    DriverManager::getConnection($params),
    ORMSetup::createAttributeMetadataConfiguration(
        paths: [__DIR__ . '/../Entities'],
        isDevMode: true, // should be false as it's production
        proxyDir: __DIR__ . '/../../../tmp',
    ),
);

Versions:

  1. PHP: 8.2
  2. Doctrine ORM: 3.1
  3. Doctrine DBAL: 4.0

I’m not using Symfony, just plain Doctrine.

How to approach this issue so that I could correctly clear the production cache?