qingbofish 发表于 2013-1-15 12:17:10

fltn03 发表于 2012-7-30 17:35 static/image/common/back.gif
有个问题想请教各位:我按下载文件中的路径替换掉了CI中的代码,为什么获取不到指定的session?当我注释掉M ...

解决了为什么注释之后就能运行。

hadi100 发表于 2013-4-7 17:14:41

今天才看到,标记学习

cowa 发表于 2013-9-6 18:54:27

发现了 CodeIgniter 缓存类的 BUG 貌似很严重的BUG

楼主啊....你写的这个有问题啊......

看这里, 这里传了 4个参数 呃
$result = $this->_memcached->replace($id, array($data, time(), $ttl), 0, $ttl);
而 MEMCACHED 提供的 API 是只能传三个参数
public bool Memcached::replace ( string $key , mixed $value [, int $expiration ] )

/**
       * Replace the cache
       *
       * @param         string                unique key
       * @param         mixed                data to store
       * @param         int                        length of time (in seconds) the cache is valid
       *                                                - Default is 60 seconds
       * @return         boolean                true on success/false on failure
       */
        public function replace($id, $data, $ttl = 60)
        {
                $result = $this->_memcached->replace($id, array($data, time(), $ttl), 0, $ttl);
                if($result === FALSE)
                {
                        $result = $this->save($id, $data, $ttl);
                }
               
                return $result;
        }



下面这里_memcached 它是new 的
$this->_memcached = new Memcached();

/**
       * Setup memcached.
       */
        private function _setup_memcached()
        {
                // Try to load memcached server info from the config file.
                $CI =& get_instance();
                if ($CI->config->load('memcached', TRUE, TRUE))
                {
                        if (is_array($CI->config->config['memcached']))
                        {
                                $this->_memcache_conf = NULL;

                                foreach ($CI->config->config['memcached'] as $name => $conf)
                                {
                                        $this->_memcache_conf[$name] = $conf;
                                }                               
                        }                       
                }
               
                $this->_memcached = new Memcached();

                foreach ($this->_memcache_conf as $name => $cache_server)
                {
                        if ( ! array_key_exists('hostname', $cache_server))
                        {
                                $cache_server['hostname'] = $this->_default_options['default_host'];
                        }
       
                        if ( ! array_key_exists('port', $cache_server))
                        {
                                $cache_server['port'] = $this->_default_options['default_port'];
                        }
       
                        if ( ! array_key_exists('weight', $cache_server))
                        {
                                $cache_server['weight'] = $this->_default_options['default_weight'];
                        }
       
                        $this->_memcached->addServer(
                                        $cache_server['hostname'], $cache_server['port'], $cache_server['weight']
                        );
                }
        }

居然 这么 粗心 .....         调了我一个下午啊.......      CI 那个也不是很完善...system 里报的错误居然...... 唉……………………………………………………………………   

Hex 发表于 2013-9-7 12:02:50

cowa 发表于 2013-9-6 18:54 static/image/common/back.gif
楼主啊....你写的这个有问题啊......

看这里, 这里传了 4个参数 呃


感谢报告问题。请问您是 2.1.0 版吗?
这个只针对这个版本。

cowa 发表于 2013-9-12 13:49:16

Hex 发表于 2013-9-7 12:02 static/image/common/back.gif
感谢报告问题。请问您是 2.1.0 版吗?
这个只针对这个版本。

不论哪个版本Memcached::replace ( string $key , mixed $value [, int $expiration ] )
Memcached 的 replace 只能接收三个参数

Hex 发表于 2013-9-12 14:55:23

cowa 发表于 2013-9-12 13:49 static/image/common/back.gif
不论哪个版本Memcached::replace ( string $key , mixed $value[ ...

我已经联系作者了。

PS: 这个东西不是我开发的。{:soso_e100:}

saturn 发表于 2013-9-12 23:53:57

cowa 发表于 2013-9-12 13:49 static/image/common/back.gif
不论哪个版本Memcached::replace ( string $key , mixed $value[ ...

谢谢,你是对的;我犯了经验主义错误。

因为之前这个库是在 PHP Memcache 拓展下开发的,而 Memcache 的 replace 方法和 lib-Memcached 拓展在第4个参数上会存在差异,稍后我会改掉;谢谢。

http://cn2.php.net/manual/en/memcache.replace.php
http://cn2.php.net/manual/en/memcached.replace.php

另外,这个库在这里:https://github.com/cnsaturn/codeigniter-my-session


cowa 发表于 2013-10-11 17:36:19

本帖最后由 cowa 于 2013-10-11 17:40 编辑

saturn 发表于 2013-9-12 23:53 static/image/common/back.gif
谢谢,你是对的;我犯了经验主义错误。

因为之前这个库是在 PHP Memcache 拓展下开发的,而 Memcache 的 ...
对了楼主还有一个问题,这个问题是属于CI框架的问题 下面是修改后的

foreach ($this->_memcache_conf as $name => $cache_server)
                {
//            print_r($this->_memcache_conf);die;
                        if ( ! array_key_exists('hostname', $cache_server))
                        {
                              //$cache_server['hostname'] = $this->_default_options['default_host'];
                              $cache_server['hostname'] = $this->_memcache_conf['memcached']['default']['default_host'];
                        }
      
                        if ( ! array_key_exists('port', $cache_server))
                        {
                              //$cache_server['port'] = $this->_default_options['default_port'];
                              $cache_server['port'] = $this->_memcache_conf['memcached']['default']['default_port'];
                        }
      
                        if ( ! array_key_exists('weight', $cache_server))
                        {
                              //$cache_server['weight'] = $this->_default_options['default_weight'];
                              $cache_server['weight'] = $this->_memcache_conf['memcached']['default']['default_weight'];
                        }
      
                        $this->_memcached->addServer(
                                        $cache_server['hostname'], $cache_server['port'], $cache_server['weight']
                        );
                }

如果使用的是 $cache_server['hostname'] = $this->_default_options['default_host'];
的话无论 config/memcached.php 配置怎么修改它都是127.0.0.1 详细的我就不说了快忘掉了    你把整个 cache 再读一遍或许就能明白,注册掉的是以前的正确的是
$cache_server['hostname'] = $this->_memcache_conf['memcached']['default']['default_host'];

目录文件:/system/libraries/Cache/drivers/Cache_memcached.php


datena 发表于 2013-10-22 16:55:24

记号

刀客孩哥 发表于 2013-11-4 15:50:03

出错了
Fatal error: Call to a member function get() on a non-object
help
页: 1 2 3 4 [5] 6 7
查看完整版本: [2.1.0]骑兵系列三:支持Memcached的Session类库