$mod = M('Test');
$data = $mod->select();
S('data',$data);
$aa = S('data');
print_r($aa);        测试正常,但是使用查询缓存$mod = M('Test');
$data = $mod->cache('test1',60)->select(); 
$aa = S('test1');
print_r($aa);这段代码测试失$aa始终为false!查看日志文件:
[ 2013-04-11T09:53:25+08:00 ] 127.0.0.1 /tp312Demo/index.php/Index/aa
INFO: [ route_check ] --START--
INFO: Run CheckRoute Behavior [ RunTime:0.017694s ]
INFO: [ route_check ] --END-- [ RunTime:0.017851s ]
INFO: [ app_begin ] --START--
INFO: Run ReadHtmlCache Behavior [ RunTime:0.010037s ]
INFO: [ app_begin ] --END-- [ RunTime:0.010166s ]
SQL: DESCRIBE test [ RunTime:0.012579s ]
NOTIC: [8] Undefined index: persistent D:\AppServ\www\tp312Demo\ThinkPHP\Lib\Driver\Cache\CacheMemcache.class.php 第 45 行.
NOTIC: [8] Undefined index: timeout D:\AppServ\www\tp312Demo\ThinkPHP\Lib\Driver\Cache\CacheMemcache.class.php 第 47 行.
NOTIC: [8] Undefined index: host D:\AppServ\www\tp312Demo\ThinkPHP\Lib\Driver\Cache\CacheMemcache.class.php 第 49 行.
NOTIC: [8] Undefined index: port D:\AppServ\www\tp312Demo\ThinkPHP\Lib\Driver\Cache\CacheMemcache.class.php 第 49 行.
NOTIC: [8] Undefined index: timeout D:\AppServ\www\tp312Demo\ThinkPHP\Lib\Driver\Cache\CacheMemcache.class.php 第 49 行.
NOTIC: [8] Memcache::connect(): Server (tcp 0, udp 0) failed with: Failed to parse address "" (0) D:\AppServ\www\tp312Demo\ThinkPHP\Lib\Driver\Cache\CacheMemcache.class.php 第 49 行.
NOTIC: [2] Memcache::connect(): Can't connect to :0, Failed to parse address "" (0) D:\AppServ\www\tp312Demo\ThinkPHP\Lib\Driver\Cache\CacheMemcache.class.php 第 49 行.
SQL: SELECT * FROM `test` [ RunTime:0.000540s ]
发现实例化memcache对象时,未获取配置的连接参数。打开CacheMemcache.class.php。修改31行
 
if(empty($options)) {
            $options = array (
                'host'        =>  C('MEMCACHE_HOST') ? C('MEMCACHE_HOST') : '127.0.0.1',
                'port'        =>  C('MEMCACHE_PORT') ? C('MEMCACHE_PORT') : 11211,
                'timeout'     =>  C('DATA_CACHE_TIMEOUT') ? C('DATA_CACHE_TIMEOUT') : false,
                'persistent'  =>  false,
            );
 }改为: if(empty($options) || ! isset($options['host'])) {            
            $options1 = array (
                'host'        =>  C('MEMCACHE_HOST') ? C('MEMCACHE_HOST') : '127.0.0.1',
                'port'        =>  C('MEMCACHE_PORT') ? C('MEMCACHE_PORT') : 11211,
                'timeout'     =>  C('DATA_CACHE_TIMEOUT') ? C('DATA_CACHE_TIMEOUT') : false,
                'persistent'  =>  false,
            );
            $options = array_merge($options1,$options);
        }测试通过!算是bug吧		最佳答案