30
30
use Symfony \Component \Cache \Adapter \AdapterInterface ;
31
31
use Symfony \Component \Cache \Adapter \ArrayAdapter ;
32
32
use Symfony \Component \Cache \Adapter \ChainAdapter ;
33
- use Symfony \Component \Cache \Adapter \RedisTagAwareAdapter ;
34
33
use Symfony \Component \Cache \Adapter \TagAwareAdapter ;
35
34
use Symfony \Component \Cache \DependencyInjection \CachePoolPass ;
36
35
use Symfony \Component \Cache \Marshaller \DefaultMarshaller ;
@@ -1854,8 +1853,11 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
1854
1853
foreach ($ config ['pools ' ] as $ name => $ pool ) {
1855
1854
$ pool ['adapters ' ] = $ pool ['adapters ' ] ?: ['cache.app ' ];
1856
1855
1856
+ $ isRedisTagAware = ['cache.adapter.redis_tag_aware ' ] === $ pool ['adapters ' ];
1857
1857
foreach ($ pool ['adapters ' ] as $ provider => $ adapter ) {
1858
- if ($ config ['pools ' ][$ adapter ]['tags ' ] ?? false ) {
1858
+ if (($ config ['pools ' ][$ adapter ]['adapters ' ] ?? null ) === ['cache.adapter.redis_tag_aware ' ]) {
1859
+ $ isRedisTagAware = true ;
1860
+ } elseif ($ config ['pools ' ][$ adapter ]['tags ' ] ?? false ) {
1859
1861
$ pool ['adapters ' ][$ provider ] = $ adapter = '. ' .$ adapter .'.inner ' ;
1860
1862
}
1861
1863
}
@@ -1870,43 +1872,33 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
1870
1872
$ pool ['reset ' ] = 'reset ' ;
1871
1873
}
1872
1874
1873
- if ($ pool ['tags ' ]) {
1875
+ if ($ isRedisTagAware ) {
1876
+ $ tagAwareId = $ name ;
1877
+ $ container ->setAlias ('. ' .$ name .'.inner ' , $ name );
1878
+ } elseif ($ pool ['tags ' ]) {
1874
1879
if (true !== $ pool ['tags ' ] && ($ config ['pools ' ][$ pool ['tags ' ]]['tags ' ] ?? false )) {
1875
1880
$ pool ['tags ' ] = '. ' .$ pool ['tags ' ].'.inner ' ;
1876
1881
}
1882
+ $ container ->register ($ name , TagAwareAdapter::class)
1883
+ ->addArgument (new Reference ('. ' .$ name .'.inner ' ))
1884
+ ->addArgument (true !== $ pool ['tags ' ] ? new Reference ($ pool ['tags ' ]) : null )
1885
+ ->setPublic ($ pool ['public ' ])
1886
+ ;
1877
1887
1878
- $ isRedis = $ definition instanceof ChildDefinition && 'cache.adapter.redis ' === $ definition ->getParent ();
1879
- if (true === $ pool ['tags ' ] && $ isRedis ) {
1880
- $ definition = new Definition (RedisTagAwareAdapter::class, [null , null , 0 , null ]);
1881
- if (!isset ($ pool ['provider ' ]) || !$ pool ['provider ' ]) {
1882
- $ pool ['provider ' ] = 'cache.default_redis_provider ' ;
1883
- }
1884
- $ underlyingAdapterName = $ name ;
1885
- } else {
1886
- $ container ->register ($ name , TagAwareAdapter::class)
1887
- ->addArgument (new Reference ('. ' .$ name .'.inner ' ))
1888
- ->addArgument (true !== $ pool ['tags ' ] ? new Reference ($ pool ['tags ' ]) : null )
1889
- ->setPublic ($ pool ['public ' ])
1890
- ;
1891
- $ underlyingAdapterName = '. ' .$ name .'.inner ' ;
1892
- }
1893
-
1894
- $ pool ['name ' ] = $ name ;
1888
+ $ pool ['name ' ] = $ tagAwareId = $ name ;
1895
1889
$ pool ['public ' ] = false ;
1896
- $ name = $ underlyingAdapterName ;
1897
-
1898
- if (!\in_array ($ pool ['name ' ], ['cache.app ' , 'cache.system ' ], true )) {
1899
- $ container ->registerAliasForArgument ($ pool ['name ' ], TagAwareCacheInterface::class);
1900
- $ container ->registerAliasForArgument ($ name , CacheInterface::class, $ pool ['name ' ]);
1901
- $ container ->registerAliasForArgument ($ name , CacheItemPoolInterface::class, $ pool ['name ' ]);
1902
- }
1890
+ $ name = '. ' .$ name .'.inner ' ;
1903
1891
} elseif (!\in_array ($ name , ['cache.app ' , 'cache.system ' ], true )) {
1904
- $ container ->register ('. ' .$ name .'.taggable ' , TagAwareAdapter::class)
1892
+ $ tagAwareId = '. ' .$ name .'.taggable ' ;
1893
+ $ container ->register ($ tagAwareId , TagAwareAdapter::class)
1905
1894
->addArgument (new Reference ($ name ))
1906
1895
;
1907
- $ container ->registerAliasForArgument ('. ' .$ name .'.taggable ' , TagAwareCacheInterface::class, $ name );
1908
- $ container ->registerAliasForArgument ($ name , CacheInterface::class);
1909
- $ container ->registerAliasForArgument ($ name , CacheItemPoolInterface::class);
1896
+ }
1897
+
1898
+ if (!\in_array ($ name , ['cache.app ' , 'cache.system ' ], true )) {
1899
+ $ container ->registerAliasForArgument ($ tagAwareId , TagAwareCacheInterface::class, $ pool ['name ' ] ?? $ name );
1900
+ $ container ->registerAliasForArgument ($ name , CacheInterface::class, $ pool ['name ' ] ?? $ name );
1901
+ $ container ->registerAliasForArgument ($ name , CacheItemPoolInterface::class, $ pool ['name ' ] ?? $ name );
1910
1902
}
1911
1903
1912
1904
$ definition ->setPublic ($ pool ['public ' ]);
0 commit comments