我得到的教程是:
http://yaminnoor.com/redis-codeigniter/ http://yaminnoor.com/redis-codeigniter/
https://codeigniter.com/user_guide/libraries/caching.html#redis https://codeigniter.com/user_guide/libraries/caching.html#redis
我尝试这样:
Config (application\config\redis.php
):
defined('BASEPATH') OR exit('No direct script access allowed');
$config['socket_type'] = 'tcp'; //`tcp` or `unix`
$config['socket'] = '/var/run/redis.sock'; // in case of `unix` socket type
$config['host'] = '127.0.0.1'; //change this to match your amazon redis cluster node endpoint
$config['password'] = NULL;
$config['port'] = 6379;
$config['timeout'] = 0;
控制器:
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Redis_tes extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->driver('cache', array('adapter' => 'redis', 'backup' => 'file'));
}
public function index() {
// die('tes');
if($this->cache->redis->is_supported() || $this->cache->file->is_supported()) {
$var1 = $this->cache->get('cache_var1');
} else {
$cache_var1 = $this->_model_data->get_var1();
$this->cache->save('cache_var1', $cache_var1);
}
}
}
?>
I run http://localhost/app_redis/redis_tes
,这会产生以下错误:
遇到错误
请求的驱动程序无效:CI_Cache_redis
有什么办法可以解决我的问题吗?
看这里:https://github.com/joelcox/codeigniter-redis https://github.com/joelcox/codeigniter-redis尝试使用这个库。
更新:该库已被弃用。作者建议迁移到 Predis。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)