-
- Notifications
You must be signed in to change notification settings - Fork 5.3k
Added the documentation for the Cache component #6515
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
23 commits Select commit Hold shift + click to select a range
7582785
Added the documentation for the Cache component
javiereguiluz 21da04e
Used a better example
javiereguiluz 05b7ba9
Tweaked the example
javiereguiluz 401410d
Added the docs for the cache items
javiereguiluz 6acd591
Added a missing file
javiereguiluz b1c5b12
Minor fixes
javiereguiluz c6917bd
Minor syntax error
javiereguiluz fc84df8
Added a missing link
javiereguiluz 599ed0a
Added the article about Cache Pools
javiereguiluz 687910d
Updated the cache pools article
javiereguiluz 2d71222
Completed the chapter about cache pools
javiereguiluz 6d21b01
First round of fixes
javiereguiluz e1bce89
Tweaked some examples
javiereguiluz 81ec988
Updated the description of ChainAdapter
javiereguiluz c44b7c2
Added docs for ProxyAdapter
javiereguiluz 11549e2
Removed useless information
javiereguiluz 930a2d1
Simplified the explanation of the cache pools
javiereguiluz 94011a7
More tweaks
javiereguiluz cf07d4a
Added the explanation of the "version" argument
javiereguiluz f2234ed
Fixed a link
javiereguiluz 1628349
Changes recommended by reviewers
javiereguiluz 657659f
Fixed the adapter of cache pools
javiereguiluz 50f0d58
Removed a "note" and improve an example
javiereguiluz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Used a better example
- Loading branch information
commit 21da04eb4a9ecbfb199676c23bad38b6d19e5e7c
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
| @@ -55,20 +55,20 @@ and define the namespace used to store the items as the first argument:: | |
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 | ||
$item = $cache->getItem('user_id'); | ||
$numProducts = $cache->getItem('stats.num_products'); | ||
| ||
// assign a value to the item and save it | ||
$item->set('4711'); | ||
$cache->save($item); | ||
$numProducts->set('4711'); | ||
$cache->save($numProducts); | ||
| ||
// retrieve the cached item | ||
$cachedUser = $cache->getItem('user_id'); | ||
// retrieve the cache item | ||
$cachedNumProducts = $cache->getItem('stats.num_products'); | ||
// check whether the item exists in the cache | ||
$isCached = $cachedUser->isHit(); | ||
$isCached = $cachedNumProducts->isHit(); | ||
// retrieve the value stored by the item | ||
$userId = $cachedUser->get(); | ||
$numProducts = $cachedNumProducts->get(); | ||
| ||
// remove the cache item | ||
$cache->deleteItem('user_id'); | ||
$cache->deleteItem('stats.num_products'); | ||
| ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's add links to the other sections in a new section at the end of the introduction | ||
.. _`PSR-6`: http://www.php-fig.org/psr/psr-6/ |
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
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.