现在的位置: 首页 > 综合 > 正文

ThinkPHP3.12+Memcach+windows的配置

2013年02月06日 ⁄ 综合 ⁄ 共 751字 ⁄ 字号 评论关闭

windows配置不在赘述。

提供以下两种测试方法。

1:echo phpinfo();
2:New Memcache(); 运行不报错即可。

TP下的安装,

首先,如果你下载的是3.12核心包,那么是不带memcache的扩展,需要在官网下载memcache3.12扩展包,地址http://www.thinkphp.cn/download/253.html。

放在系统目录下的Extend,默认这里只有一给“读我.txt”。

TP下的配置,

S(array('type'=>'Memcache','host'=>'localhost','port'=>'11211','expire'=>60));  //设置Mem信息

1:官方建议S替代Cache方法。

2:type代表缓存类型 host代表主机,port代表端口,expire代表缓存时间。

TP下的试用

S(array('type'=>'Memcache','host'=>'localhost','port'=>'11211','expire'=>60));  //设置Mem信息

S('key','value'); //设置key值。

$value=S('key'); 获取K值

TP下的数据库交互,

  

S(array('type'=>'Memcache','host'=>'localhost','port'=>'11211','expire'=>60));  //设置Mem信息
        $Mod=D('Test');                                                                             
        $arr=$Mod->Mem();                 // mem()写在model,主要就是获取表内所有数据
        if($arr1=S('Key2')){              //如果存在则读取,否则重新赋值
            print_r($arr1);
        }
        else{
            S('Key2',$arr);
            print_r(S('Key2'));
        }


    }

抱歉!评论已关闭.