На https://github.com/iMateo/oc2-mysqli-cached нашел вроде такой драйвер, но он что то не работает хотя сайт в рабочем состоянии. Версия opencart 1.5.4.1. Ниже содержимое файла mysqli_cached.php
<?php
final class MySQLi_Cached {
private $link;
private $cache;
private $cachedquery;
public function __construct($hostname, $username, $password, $database, $port = '3306') {
$this->cache = new Cache(DB_CACHED_EXPIRE);
$this->link = new mysqli($hostname, $username, $password, $database, $port);
if ($this->link->connect_error) {
trigger_error('Error: Could not make a database link (' . $this->link->connect_errno . ') ' . $this->link->connect_error);
exit();
}
$this->link->set_charset("utf8");
$this->link->query("SET SQL_MODE = ''");
$this->link->query("SET NAMES 'utf-8");
$this->link->query("SET CHARACTER_SET_CONNECTION=utf8");
$this->link->query("SET SQL_MODE = ''");
$this->link->query("SET SESSION wait_timeout = 3600");
}
public function query($sql) {
$isselect = 0;
$md5query = '';
$pos = stripos($sql, 'select ');
if ($pos == 0) {
$isselect = 1;
$md5query = md5($sql);
if ($query = $this->cache->get('sql_' . $md5query)) {
if ($query->sql == $sql) {
if ($resetflag = $this->cache->get('sql_globalresetcache')) {
if ($resetflag <= $query->time) {
$this->cachedquery = $query;
return($query);
} else {
$this->cachedquery = $query;
return($query);
}
}
}
}
$resource = $this->link->query($sql);
if ($resource) {
if (is_resource($resource)) {
$i = 0;
$data = array();
while ($result = $query->fetch_accoc($resource)) {
$data[$i] = $result;
$i++;
}
}
}
}
$query = $this->link->query($sql);
if (!$this->link->errno) {
if ($query instanceof mysqli_result) {
$data = array();
while ($row = $query->fetch_assoc()) {
$data[] = $row;
}
$result = new stdClass();
$result->num_rows = $query->num_rows;
$result->row = isset($data[0]) ? $data[0] : array();
$result->rows = $data;
unset($data);
if ($isselect == 1) {
$result->sql = $sql;
$result->time = time();
$this->cache->set('sql_' . $md5query, $result);
};
unset($this->cachedquery);
$query->close();
return $result;
} else {
return true;
}
} else {
trigger_error('Error: ' . $this->link->error . '<br />Error No: ' . $this->link->errno . '<br />' . $sql);
}
}
public function escape($value) {
return $this->link->real_escape_string($value);
}
public function countAffected() {
if (isset($this->cachedquery) && $this->cachedquery) {
return $this->cachedquery->num_rows;
} else {
return $this->link->affected_rows;
}
}
public function getLastId() {
return $this->link->insert_id;
}
public function __destruct() {
$this->link->close();
}
}