When I run doctrine orm:clear-cache:metadata I noticed that it clears everything within the cache, even items which have nothing to do with Doctrine at all.
In looking into the various driver implementations it seems that the AbstractCache->deleteAll() depends on getIds of each cache driver, yet the getIds of XcacheCache and MemcacheCache drivers seem to just get every single item within the cache.
This has several implications:
- clearing metadata cache actually clears query cache and any other Doctrine cache using the same cache driver
- clearing Doctrine cache of one project actually clears caches of every project using the same cache container
- clearing Doctrine cache clears every object cached within that container, leading to increased risk of cache stampeding
In looking at the stored cache data it seems possible to fix #2 by using the Namespace of that project when executing a cache clear. it also seems possible to use the cache driver's deleteByRegex() to solve #1 by deleting only items listed as metadata cache vs query cache. Fixing #1 and #2 automatically fixes concern #3
Or, as an alternative, I could suggest that deleteAll() in MetaDataCommand should be replaced by: