-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Update cache_pools.rst #7451
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
Update cache_pools.rst #7451
Conversation
When retrieving an item from cache you have to use `getItem()` and not `get()` The `Psr\Cache\CacheItemPoolInterface` doesn't declare the `get` method
@@ -282,7 +282,7 @@ item in the cache immediately (it returns ``true`` if the item was saved or | |||
``false`` if some error occurred):: | |||
|
|||
// ... | |||
$userFriends = $cache->get('user_'.$userId.'_friends'); | |||
$userFriends = $cache->getItem('user_'.$userId.'_friends'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now also need to call get()
on the return value (the cache pool does not return the cached value, but a CacheItemInterface
instance).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just about saving cache items.
I don't think it is necessary to get the value if you just want to save the value into cache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah indeed, I misread the following code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Status: Reviewed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Good catch, thanks @crislinu. |
This PR was merged into the 3.2 branch. Discussion ---------- Update cache_pools.rst When retrieving an item from cache you have to use `getItem()` and not `get()` The `Psr\Cache\CacheItemPoolInterface` doesn't declare the `get` method Commits ------- 398892e Update cache_pools.rst
When retrieving an item from cache you have to use
getItem()
and notget()
The
Psr\Cache\CacheItemPoolInterface
doesn't declare theget
method