Skip to content

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

Merged
merged 1 commit into from
Feb 19, 2017
Merged

Update cache_pools.rst #7451

merged 1 commit into from
Feb 19, 2017

Conversation

crislinu
Copy link
Contributor

@crislinu crislinu commented Feb 6, 2017

When retrieving an item from cache you have to use getItem() and not get()

The Psr\Cache\CacheItemPoolInterface doesn't declare the get method

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');
Copy link
Member

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).

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member

@xabbuh xabbuh left a comment

Choose a reason for hiding this comment

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

👍

Status: Reviewed

Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

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

👍

@xabbuh
Copy link
Member

xabbuh commented Feb 19, 2017

Good catch, thanks @crislinu.

@xabbuh xabbuh merged commit 398892e into symfony:3.2 Feb 19, 2017
xabbuh added a commit that referenced this pull request Feb 19, 2017
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants