|
完全安装官方的做法:
1. config.php 文件中配置
$config['sess_driver'] = 'memcached';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = '192.168.1.124:11211';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
2.使用
$this->load->library('session');
$this->session->set_userdata('test_item','haha2');
3.出错:
\system\libraries\Session\drivers\Session_memcached_driver.php on line 108
<h4>A PHP Error was encountered</h4>
<p>Severity: Error</p>
<p>Message: Class 'Memcached' not found</p>
<p>Filename: drivers/Session_memcached_driver.php</p>
<p>Line Number: 108</p>
4.php memcached扩展已装
extension=php_memcache.dll 版本也对
5.直接使用memcached ,可以使用
$this->load->driver('cache');
$this->cache->memcached->save('foo', 'bar', 1000);
$result = $this->cache->memcached->get_metadata('foo');
结果:
<h2>Array
(
[expire] => 1472037980
[mtime] => 1472036980
[data] => bar
)
</h2>
6.config目录下的memcached.php 配置如下:
$config = array(
// 'default' => array(
// 'hostname' => '127.0.0.1',
// 'port' => '11211',
// 'weight' => '1',
// ),
'default' => array(
'hostname' => '192.168.1.124',
'port' => '11211',
'weight' => '1',
),
);
7.但是session一用memcached驱动就报错误 如3所示。
8.求助、求助、求助
|
|