PHP memcached 各种数据类型存储



 connect('localhost',11211);

//③ 标量类型(int string boolean float) 信息的存储,会转成字符串存储。
$me -> set('age',23,0);  //"23"
$me -> set('name','jim',0);  //"jim"
$me -> set('ismarried',false,0);  //""
$me -> set('height',175.2,0);   //"175.2"


//④ 复合类型(array object null) 信息的存储,会原型存储(原样存储会浪费系统资源,一般要序列化成字符串 serialize()  unserialize())
$color = array('red','blue','green');
class Person{
    //类的成员属性必须设置修饰符(public[var]/protected/private),否则报错
    public $name = "mary";
    public $addr = "beijing";
    public $weight = 120;
    function run(){
        echo "She is running";
    }
}
$per = new Person();
$me -> set('yanse',$color,0);  //array
$me -> set('dui',$per,0);    //object
$me -> set('kong',null,0);   //NULL


你可能感兴趣的:(PHP)