Skip to content

Commit

Permalink
Update documentation for Model::_readDataSource()
Browse files Browse the repository at this point in the history
Update sample code to generate unique keys based on association
conditions as well. Because association conditions are not part of the
'query' they need to be handled separately.

Refs #8346
  • Loading branch information
markstory committed Feb 26, 2016
1 parent 31b3f39 commit 1709f54
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/Cake/Model/Model.php
Expand Up @@ -3011,15 +3011,15 @@ public function find($type = 'first', $query = array()) {
*
* ```
* protected function _readDataSource($type, $query) {
* $cacheName = md5(json_encode($query));
* $cache = Cache::read($cacheName, 'cache-config-name');
* if ($cache !== false) {
* return $cache;
* }
*
* $results = parent::_readDataSource($type, $query);
* Cache::write($cacheName, $results, 'cache-config-name');
* return $results;
* $cacheName = md5(json_encode($query) . json_encode($this->hasOne) . json_encode($this->belongsTo));
* $cache = Cache::read($cacheName, 'cache-config-name');
* if ($cache !== false) {
* return $cache;
* }
*
* $results = parent::_readDataSource($type, $query);
* Cache::write($cacheName, $results, 'cache-config-name');
* return $results;
* }
* ```
*
Expand Down

0 comments on commit 1709f54

Please sign in to comment.