/** * Fetch the results for this query. * * Will return either the results set through setResult(), or execute this query * and return the ResultSetDecorator object ready for streaming of results. * * ResultSetDecorator is a traversable object that implements the methods found * on Cake\Collection\Collection. * * @return \Cake\Datasource\ResultSetInterface */ public function all() { if (isset($this->_results)) { return $this->_results; } if ($this->_cache) { $results = $this->_cache->fetch($this); } if (!isset($results)) { $results = $this->_decorateResults($this->_execute()); if ($this->_cache) { $this->_cache->store($this, $results); } } $this->_results = $results; return $this->_results; }
/** * Fetch the results for this query. * * Will return either the results set through setResult(), or execute this query * and return the ResultSetDecorator object ready for streaming of results. * * ResultSetDecorator is a traversable object that implements the methods found * on Cake\Collection\Collection. * * @return \Cake\Datasource\ResultSetInterface */ public function all() { if (isset($this->_results)) { return $this->_results; } $table = $this->repository(); $table->dispatchEvent('Model.beforeFind', [$this, $this->_options, !$this->eagerLoaded()]); if (isset($this->_results)) { return $this->_results; } if ($this->_cache) { $results = $this->_cache->fetch($this); } if (!isset($results)) { $results = $this->_decorateResults($this->_execute()); if ($this->_cache) { $this->_cache->store($this, $results); } } $this->_results = $results; return $this->_results; }
/** * Test fetching with a cache miss. * * @return void */ public function testFetchCacheMiss() { $this->_mockRead('my_key', false); $cacher = new QueryCacher('my_key', $this->engine); $query = $this->getMock('stdClass'); $result = $cacher->fetch($query); $this->assertNull($result, 'Cache miss should not have an isset() return.'); }