PHP操作memcache(增刪改查)
阿新 • • 發佈:2019-01-02
<?php header("content-type:text/html;charset=utf-8"); $mem=new Memcache(); //var_dump($mem); $mem->connect("127.0.0.1","11211"); //$mem->set("name","cuijinpeng",0,20); //echo $mem->get("name"); //物件的操作 //class Dog{ // public $name; // public $age; // public function __construct($name,$age){ // $this->name = $name;// $this->age = $age; // } //} //$dog=new Dog('dog','12'); //$dog=$mem->add("dog",$dog,MEMCACHE_COMPRESSED,0); //var_dump($dog); //可以操作資料、字串、陣列、物件。。。 //新增資料 $mem->add("name","admin",MEMCACHE_COMPRESSED,0); //修改資料 $mem->set("name","xiaohua",MEMCACHE_COMPRESSED,0); //replace的使用 $mem->replace("name","xiaobai",MEMCACHE_COMPRESSED,0); //刪除資料 $mem->delete("name"); //echo $mem->get("name"); ?>