Skip to content

Commit c9fd7dc

Browse files
Add support for NamespacedPoolInterface
1 parent ed34b0c commit c9fd7dc

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"guzzlehttp/psr7": "^2.1.1",
1717
"jean85/pretty-package-versions": "^1.5||^2.0",
1818
"sentry/sentry": "^4.14.1",
19-
"symfony/cache-contracts": "^1.1||^2.4||^3.0",
19+
"symfony/cache-contracts": "^1.1||^2.4||^3.6",
2020
"symfony/config": "^4.4.20||^5.0.11||^6.0||^7.0",
2121
"symfony/console": "^4.4.20||^5.0.11||^6.0||^7.0",
2222
"symfony/dependency-injection": "^4.4.20||^5.0.11||^6.0||^7.0",

src/Tracing/Cache/TraceableCacheAdapterForV3.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
use Symfony\Component\Cache\PruneableInterface;
1010
use Symfony\Component\Cache\ResettableInterface;
1111
use Symfony\Contracts\Cache\CacheInterface;
12+
use Symfony\Contracts\Cache\NamespacedPoolInterface;
1213

1314
/**
1415
* This implementation of a cache adapter supports the distributed tracing
1516
* feature of Sentry.
1617
*
1718
* @internal
1819
*/
19-
final class TraceableCacheAdapterForV3 implements AdapterInterface, CacheInterface, PruneableInterface, ResettableInterface
20+
final class TraceableCacheAdapterForV3 implements AdapterInterface, NamespacedPoolInterface, CacheInterface, PruneableInterface, ResettableInterface
2021
{
2122
/**
2223
* @phpstan-use TraceableCacheAdapterTrait<AdapterInterface>
@@ -48,4 +49,16 @@ public function get(string $key, callable $callback, ?float $beta = null, ?array
4849
return $this->decoratedAdapter->get($key, $callback, $beta, $metadata);
4950
}, $key);
5051
}
52+
53+
public function withSubNamespace(string $namespace): static
54+
{
55+
if (!$this->decoratedAdapter instanceof NamespacedPoolInterface) {
56+
throw new \BadMethodCallException(\sprintf('The %s::withSubNamespace() method is not supported because the decorated adapter does not implement the "%s" interface.', self::class, NamespacedPoolInterface::class));
57+
}
58+
59+
$clone = clone $this;
60+
$clone->decoratedAdapter = $this->decoratedAdapter->withSubNamespace($namespace);
61+
62+
return $clone;
63+
}
5164
}

0 commit comments

Comments
 (0)