Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use symfony/cache to convert doctrine/cache to PSR-6 and back #1

Conversation

alcaeus
Copy link

@alcaeus alcaeus commented Dec 3, 2019

No description provided.

@@ -43,9 +47,12 @@ public function __construct($lifetime = 0, ?string $cacheKey = null, ?object $re
if ($resultCache instanceof Cache) {
@trigger_error(sprintf('Using an instance of %s as result cache is deprecated. Please provide a PSR-6 cache instead.', Cache::class), E_USER_DEPRECATED);

$resultCache = new DoctrineCachePool($resultCache);
$resultCache = new DoctrineAdapter($resultCache);
$this->resultCacheDriver = $resultCache;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we can't unwrap a DoctrineAdapter, we store a doctrine/cache in a separate property for later returning.

@@ -43,9 +47,12 @@ public function __construct($lifetime = 0, ?string $cacheKey = null, ?object $re
if ($resultCache instanceof Cache) {
@trigger_error(sprintf('Using an instance of %s as result cache is deprecated. Please provide a PSR-6 cache instead.', Cache::class), E_USER_DEPRECATED);

$resultCache = new DoctrineCachePool($resultCache);
$resultCache = new DoctrineAdapter($resultCache);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a small type mismatch here, since the Symfony adapter takes a CacheProvider instead of a Cache.

@alcaeus alcaeus force-pushed the improvement/psr-6-result-cache branch from a74f03a to 3e30e66 Compare December 3, 2019 16:12
@derrabus derrabus merged commit 66d5b34 into derrabus:improvement/psr-6-result-cache Dec 3, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants