dbDriver = $dbDriver; $this->cacheEngine = $cacheEngine; $this->timeToCache = $timeToCache; } /** * @param string $sql * @param null $params * @return GenericIterator * @throws InvalidArgumentException * @throws \ByJG\Serializer\Exception\InvalidArgumentException */ public function getIterator($sql, $params = null) { $key = $this->getQueryKey($sql, $params); // Get the CACHE $cacheItem = $this->cacheEngine->getItem($key); if (!$cacheItem->isHit()) { $iterator = $this->dbDriver->getIterator($sql, $params); $cacheItem->set($iterator->toArray()); $cacheItem->expiresAfter(DateInterval::createFromDateString($this->timeToCache . " seconds")); $this->cacheEngine->save($cacheItem); } $arrayDS = new ArrayDataset($cacheItem->get()); return $arrayDS->getIterator(); } protected function array_map_assoc($callback, $array) { $r = array(); foreach ($array as $key=>$value) { $r[$key] = $callback($key, $value); } return $r; } protected function getQueryKey($sql, $array) { $key1 = md5($sql); $key2 = ""; // Check which parameter exists in the SQL if (is_array($array)) { $key2 = md5(":" . implode(',', $this->array_map_assoc(function($k,$v){return "$k:$v";},$array))); } return "qry:" . $key1 . $key2; } public function getScalar($sql, $array = null) { $this->dbDriver->getScalar($sql, $array); } public function getAllFields($tablename) { $this->dbDriver->getAllFields($tablename); } public function execute($sql, $array = null) { $this->dbDriver->execute($sql, $array); } public function beginTransaction() { $this->dbDriver->beginTransaction(); } public function commitTransaction() { $this->dbDriver->commitTransaction(); } public function rollbackTransaction() { $this->dbDriver->rollbackTransaction(); } public function getDbConnection() { return $this->dbDriver->getDbConnection(); } public function setAttribute($name, $value) { $this->dbDriver->setAttribute($name, $value); } public function getAttribute($name) { $this->dbDriver->getAttribute($name); } public function executeAndGetId($sql, $array = null) { $this->dbDriver->executeAndGetId($sql, $array); } public function getDbHelper() { return $this->dbDriver->getDbHelper(); } /** * @return Uri */ public function getUri() { return $this->dbDriver->getUri(); } public function isSupportMultRowset() { return $this->dbDriver->isSupportMultRowset(); } public function setSupportMultRowset($multipleRowSet) { $this->dbDriver->setSupportMultRowset($multipleRowSet); } } __halt_compiler();----SIGNATURE:----BczD7NwzFmdeTGRu3HFaIk2dq2OFoBuQLwIgVyfVWxaFhaEswkDENFm35MRnXfbRFcUgo3RZZP1E97Nkcjart5z1jlkDv+tz1MhAJQauYTFzOIdTbAhAj8h7/HSWCAcJQa8HWuuOHNMX1RWa/B1lR5GWw5z+WVO6fP23cZov8ECPrjV2wlMiCHufHoV5kpvRiBvievLdTA5pVsdSXM0XVtVPTFhIgAusYWcSk2xW3UkYj7peZ359bwnLox70UAcCLQ/XcWsQ+0irjXQ2iZXr98t2xTI9BsQV+3FW/Hbe2/popLeDtl95MAekOM/tP1ISrv3TDFYVsr81R1VbU37c5gMivhFpp5x6JB6p+yKT/SfzuSxALuEbFIAwHn0Y2wL3mhILOqdMW/zE7SnjNyJr8VOFHb+l9WnbOiZLPES7JSMr5Tu+/r6HOI0h2oMXcDLPvuNWI8N9B39Mk+JUrgrCQwcCgdVaEvRAK0mADFYRNMlngML1K7dYLiukjk90XY1SY7cDczdYxl4aSob31la9QoZv3PHp8oorZ8cV0IobTCe8lyX00lBtdGVKfwq54KKchGySjy7w5WoX9lQ79d5vsw/PFaUcVTNj8B1KD11y6QwBfCg8xyqPlfIOwMDmHR0WBMTfrsYrdzGzqvLy24nkx6uHbqplkOOV225x8meUusE=----ATTACHMENT:----NjUyMTg1ODc3ODU4MzY4MCAzMDgzMDc2MzA3NzU3MzQxIDc0MjM2NjAzMjQ1NzU5ODE=