Py学习  »  Redis

如何修复:致命错误:找不到Opencart类“Redis”

Ivan • 2 年前 • 219 次点击  

我正在使用Opencart 2.0,并试图通过以下方式设置Redis缓存 Guide

但是我有一个错误,我不明白为什么,有人能告诉我如何解决这个问题吗?

错误

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

雷迪斯。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->expire(CACHE_PREFIX . $key, $this->expire);
        }
        return $status;
    }
    public function delete($key) {
        $this->cache->delete(CACHE_PREFIX . $key);
    }
}

隐藏物php

<?php
class Cache {
    private $cache;

    public function __construct($driver, $expire = 3600) {
        $class = 'Cache\\' . $driver;

        if (class_exists($class)) {
            $this->cache = new $class($expire);
        } else {
            exit('Error: Could not load cache driver ' . $driver . ' cache!');
        }
    }

    public function get($key) {
        return $this->cache->get($key);
    }

    public function set($key, $value) {
        return $this->cache->set($key, $value);
    }

    public function delete($key) {
        return $this->cache->delete($key);
    }
}
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/127900
 
219 次点击