Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Breaking out the find so that it can be easily overloaded for caching
Before this commit you have to do some hacks to cache model finds easily. When using custom find methods like `find('foo')` => `_findFoo(...)` it is common for the method to adjust the query params. Trying to cache a query using a hash of the query params : function find($type, $query) { $query = $this->_beforeFind($query); $cacheKey = $type . '_' . md5(selialize($query)); $cache = Cache::read($cachKey, 'my_cache'); if ($cacheKey !== false) { return $cache; } $results = $this->_afterFind($type, $query); Cache::write($cacheKey, $results, 'my_cache'); return $results; } Before this commit you either have to completely overload find and rewrite it in the AppModel or call the before to get the modified `$query` and let cake run the before again.
- Loading branch information