Skip to content

Commit 885495a

Browse files
committed
minor #2410 [Icons] use dedicated cache pool (IndraGunawan)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- [Icons] use dedicated cache pool | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Issues | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT based on `@stof` comment on EasyAdminBundle repository EasyCorp/EasyAdminBundle#6507 (comment) > you should probably create a dedicated cache pool inheriting its configuration from cache.system instead of using cache.system directly. this is how core Symfony components work (allowing them to avoid having to care about conflicting keys between the caches of different component, as the key only needs to be unique inside the cache pool) Commits ------- 62f7c03 [Icons] use dedicated cache pool
2 parents 7bd9e0f + 62f7c03 commit 885495a

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

src/Icons/config/iconify.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
->set('.ux_icons.iconify', Iconify::class)
2929
->args([
30-
service('cache.system'),
30+
service('.ux_icons.cache'),
3131
abstract_arg('endpoint'),
3232
service('http_client')->nullOnInvalid(),
3333
])

src/Icons/config/services.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@
2424

2525
return static function (ContainerConfigurator $container): void {
2626
$container->services()
27+
->set('.ux_icons.cache')
28+
->parent('cache.system')
29+
->private()
30+
->tag('cache.pool')
31+
2732
->set('.ux_icons.cache_icon_registry', CacheIconRegistry::class)
2833
->args([
2934
service('.ux_icons.chain_registry'),
30-
service('cache.system'),
35+
service('.ux_icons.cache'),
3136
])
3237

3338
->set('.ux_icons.local_svg_icon_registry', LocalSvgIconRegistry::class)

src/Icons/src/Iconify.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public function chunk(string $prefix, array $names): iterable
196196

197197
private function sets(): \ArrayObject
198198
{
199-
return $this->sets ??= $this->cache->get('ux-iconify-sets', function () {
199+
return $this->sets ??= $this->cache->get('iconify-sets', function () {
200200
$response = $this->http->request('GET', '/collections');
201201

202202
return new \ArrayObject($response->toArray());

src/Icons/src/Registry/CacheIconRegistry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function get(string $name, bool $refresh = false): Icon
3434
}
3535

3636
return $this->cache->get(
37-
\sprintf('ux-icon-%s', Icon::nameToId($name)),
37+
Icon::nameToId($name),
3838
fn () => $this->inner->get($name),
3939
beta: $refresh ? \INF : null,
4040
);

0 commit comments

Comments
 (0)