There is a Redis cache driver in Opencart 2.3
system/library/cache/redis.php
<?php
namespace Cache;
class Redis {
private $expire;
private $cache;
public function __construct($expire) {
$this->expire = $expire;
$this->cache = new \Redis();
$this->cache->pconnect(CACHE_HOSTNAME, CACHE_PORT);
}
public function get($key) {
$data = $this->cache->get(CACHE_PREFIX . $key);
return json_decode($data, true);
}
public function set($key,$value) {
$status = $this->cache->set(CACHE_PREFIX . $key,
json_encode($value));
if($status){
$this->cache->setTimeout(CACHE_PREFIX . $key, $this->expire);
}
return $status;
}
public function delete($key) {
$this->cache->delete(CACHE_PREFIX . $key);
}
}
I putted the following in /config.php
// CACHE
define('CACHE_DRIVER', 'redis');
define('REDIS_HOSTNAME', 'localhost');
define('REDIS_PORT', '6379');
define('CACHE_PREFIX', 'oc_');
it's showing error
Fatal error: Uncaught Error: Class 'Redis' not found in /system/library/cache/redis.php:8 Stack trace: #0 /system/library/cache.php(9): Cache\Redis->__construct(3600) #1 /system/framework.php(49): Cache->__construct('redis', 3600) #2 /system/startup.php(124): require_once('/home/system/...') #3 /public_html/index.php(19): start('catalog') #4 {main} thrown in /system/library/cache/redis.php on line 8
Any idea what's wrong ?
