mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Update documentation for Model::_readDataSource()
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
This commit is contained in:
parent
31b3f39b67
commit
1709f54e38
1 changed files with 8 additions and 8 deletions
|
@ -3011,15 +3011,15 @@ class Model extends Object implements CakeEventListener {
|
||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* protected function _readDataSource($type, $query) {
|
* protected function _readDataSource($type, $query) {
|
||||||
* $cacheName = md5(json_encode($query));
|
* $cacheName = md5(json_encode($query) . json_encode($this->hasOne) . json_encode($this->belongsTo));
|
||||||
* $cache = Cache::read($cacheName, 'cache-config-name');
|
* $cache = Cache::read($cacheName, 'cache-config-name');
|
||||||
* if ($cache !== false) {
|
* if ($cache !== false) {
|
||||||
* return $cache;
|
* return $cache;
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* $results = parent::_readDataSource($type, $query);
|
* $results = parent::_readDataSource($type, $query);
|
||||||
* Cache::write($cacheName, $results, 'cache-config-name');
|
* Cache::write($cacheName, $results, 'cache-config-name');
|
||||||
* return $results;
|
* return $results;
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue