-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Added the documentation for the Cache component #6515
Conversation
Now you can create, retrieve, updated and delete items using this cache pool:: | ||
|
||
// create a new item by trying to get it from the cache | ||
$numProducts = $cache->getItem('stats.num_products'); |
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.
The variable naming is confusing... What about $numProductsCacheItem
?
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.
Nice catch. I refactored this example before and forgot to update that part. It's updated now. Thanks.
Update the docs for the cache items has been added. Next chapter: cache pools. |
Update in 599ed0a I've added an article about "Cache Pools". I have two questions:
Thanks! |
This is how to create cache pools with FrameworkBundle: https://github.com/nicolas-grekas/symfony/blob/84b48de2998524558c1b027763f9af0dbc29f298/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache.yml |
It's also possible to override cache pools used by various Symfony services: #6171 (comment) |
@teohhanhui thanks ... but right now we are documenting the component. The integration with Symfony (and FrameworkBundle) will be documented later. So the question remains: how to create a cache pool with the Cache component? |
From PSR-6:
|
If by "cache pool" you mean On the other hand, cache pools as per the |
Update: finished the first version of the doc for the Cache component. @tgalopin @nicolas-grekas when you have some time, please review the docs of this PR and tell me what you think. After that, I'll write the docs about integrating Cache in Symfony framework. Thanks! |
Cache Items | ||
=========== | ||
|
||
Cache items are each one of the information units stored in the cache as a |
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.
Cache items are each one of the information units (or looks strange to me)
maybe this case can be added as note to; $cache = new FilesystemAdapter('foo', 3600);
$cacheItem = $cache->getItem('bar');
$cacheItem->set('baz');
// the cacheItem will not expire after 3600 seconds, it'll live forever
$cache->save($cacheItem);
// you need to call expiresAfter or expiresAt with null parameter if you want to use defaultLifetime
$cacheItem->expiresAfter(null);
// the cacheItem will expire after 3600 seconds
$cache->save($cacheItem); |
.. note:: | ||
|
||
In Symfony applications this component is integrated (and enabled by | ||
default) through the FrameworkBundle. |
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 don't have this note for other components as well, what about removing it here?
time to merge this one, features for 3.2 are coming :) |
.. note:: | ||
|
||
Creating a cache item and setting its value is not enough to save it in the | ||
cache. You must execute the ``save()`` method explicitly on the cache pool. |
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.
Why not showing this directly in the example above?
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.
@javiereguiluz What do you think about this? Besides this to me this one is ready to be merged.
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.
I've implemented this change.
Finally merging something would be great because searching through these PRs, tests and DI config is not very helpful in understanding how to set it up correctly. AFAIR there even wasn't any "New in Symfony" article about this PSR6 cache. |
@eXtreme you are right. And the "New in Sf" article about the Cache is pending too. |
Status: reviewed 👍 |
I've made all the requested changes. I beg Doc Maintainers to merge this before someone else asks for more changes 😄 Thanks! |
…eguiluz) This PR was submitted for the master branch but it was merged into the 3.1 branch instead (closes #6515). Discussion ---------- Added the documentation for the Cache component This fixes #6171. This is WIP because there's more documentation to come ... but you can already review the proposed documentation. Thanks! Commits ------- 6ddde65 Added the documentation for the Cache component
It took us some time. But now we are there. Thank you for writing the documentation, Javier! |
This fixes #6171.
This is WIP because there's more documentation to come ... but you can already review the proposed documentation. Thanks!