Cake\ORM\Query::cache PHP Method

cache() public method

{@inheritDoc}
public cache ( $key, $config = 'default' )
    public function cache($key, $config = 'default')
    {
        if ($this->_type !== 'select' && $this->_type !== null) {
            throw new RuntimeException('You cannot cache the results of non-select queries.');
        }
        return $this->_cache($key, $config);
    }

Usage Example

 public function findCached(Query $query, array $options)
 {
     if ($conditions = $query->clause('where')) {
         $query->cache(function ($q) use($conditions) {
             return $this->table() . '-' . md5(serialize($conditions));
         });
     }
     return $query;
 }
All Usage Examples Of Cake\ORM\Query::cache