乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      redis thinkphp

       丶平上 2016-12-08
      1. <?php 
      2. /** 
      3. * redis添加數(shù)據(jù) 
      4. * Enter description here ... 
      5. * @author Administrator 
      6. */ 
      7. class AddAction extends Action{ 
      8.     /** 
      9.      * list類型 
      10.      * Enter description here ... 
      11.      */ 
      12.     public function lists(){ 
      13.         $Redis=new RedisModel("list11"); 
      14.         //一次只能推送一條       
      15.         echo $Redis->add("ceiba"); 
      16.     } 
      17.      /** 
      18.      * 字符串類型 
      19.      * Enter description here ... 
      20.      */ 
      21.     public function string(){ 
      22.         $Redis=new RedisModel(); 
      23.         $data=array
      24.             "str1"=>"ceiba", //一個key,對應一個值 
      25.             "str2"=>"李開湧", 
      26.             "str3"=>"李明", 
      27.         ); 
      28.         echo $Redis->type("string")->add($data); 
      29.     } 
      30.     /** 
      31.      * HASH類型 
      32.      * Enter description here ... 
      33.      */ 
      34.     public function hash(){ 
      35.         $Redis=new RedisModel("user:1"); 
      36.              $data=array
      37.                "field1"=>"ceiba", //一個key,對應一個值 
      38.                "field2"=>"李開湧", 
      39.                "field3"=>"李明", 
      40.              ); 
      41.              //支持批量添加 
      42.              echo $Redis->type("hash")->add($data);        
      43.     } 
      44.      /** 
      45.      * 集合類型 
      46.      * Enter description here ... 
      47.      */ 
      48.     public function sets(){ 
      49.              $Redis=new RedisModel("sets:1"); 
      50.         //一次只能推送一條       
      51.         echo $Redis->type("sets")->add("ceiba"); 
      52.     } 
      53.       /** 
      54.      * 有序集合 
      55.      * Enter description here ... 
      56.      */ 
      57.     public function zset(){  
      58.         $Redis=new RedisModel("zset:1"); 
      59.         //支持批量添加 
      60.         $data=array
      61.             //排序=>值 
      62.             "10"=>"ceiba", 
      63.             "11"=>"李開湧", 
      64.             "12"=>"李明" 
      65.         );       
      66.         echo $Redis->type("zset")->add($data); 
      67.     } 
      68. ?> 
      1. <?php  
      2. /**  
      3.  * redis添加數(shù)據(jù)  
      4.  * Enter description here ...  
      5.  * @author Administrator  
      6.  *  
      7.  */  
      8. class AddAction extends Action{  
      9.     /**  
      10.      * list類型  
      11.      * Enter description here ...  
      12.      */  
      13.     public function lists(){  
      14.         $Redis=new RedisModel("list11");  
      15.         //一次只能推送一條        
      16.         echo $Redis->add("ceiba");  
      17.     }  
      18.      /**  
      19.      * 字符串類型  
      20.      * Enter description here ...  
      21.      */  
      22.     public function string(){  
      23.         $Redis=new RedisModel();  
      24.         $data=array(  
      25.             "str1"=>"ceiba", //一個key,對應一個值  
      26.             "str2"=>"李開湧",  
      27.             "str3"=>"李明",  
      28.         );  
      29.         echo $Redis->type("string")->add($data);  
      30.     }  
      31.     /**  
      32.      * HASH類型  
      33.      * Enter description here ...  
      34.      */  
      35.     public function hash(){  
      36.         $Redis=new RedisModel("user:1");  
      37.              $data=array(  
      38.                "field1"=>"ceiba", //一個key,對應一個值  
      39.                "field2"=>"李開湧",  
      40.                "field3"=>"李明",  
      41.              );  
      42.              //支持批量添加  
      43.              echo $Redis->type("hash")->add($data);         
      44.     }  
      45.      /**  
      46.      * 集合類型  
      47.      * Enter description here ...  
      48.      */  
      49.     public function sets(){  
      50.              $Redis=new RedisModel("sets:1");  
      51.         //一次只能推送一條        
      52.         echo $Redis->type("sets")->add("ceiba");  
      53.     }  
      54.       /**  
      55.      * 有序集合  
      56.      * Enter description here ...  
      57.      */  
      58.     public function zset(){   
      59.         $Redis=new RedisModel("zset:1");  
      60.         //支持批量添加  
      61.         $data=array(  
      62.             //排序=>值  
      63.             "10"=>"ceiba",  
      64.             "11"=>"李開湧",  
      65.             "12"=>"李明"  
      66.         );        
      67.         echo $Redis->type("zset")->add($data);  
      68.     }  
      69. }  
      70. ?>  

      2、查詢數(shù)據(jù)

      1. <?php 
      2. // redis查詢數(shù)據(jù) 
      3. class IndexAction extends Action { 
      4.     public function page(){ 
      5.         $this->display(); 
      6.     } 
      7.     /** 
      8.      * 列表類型,默認類型 
      9.      * Enter description here ... 
      10.      */ 
      11.     public function lists(){ 
      12.         //dump(C("REDIS_HOST"));  
      13.         $Redis=new RedisModel("list1"); 
      14.         $field=array
      15.             "nmae","age","pro" 
      16.         ); 
      17.         $data=$Redis->field($field)->select(); 
      18.         dump($data); 
      19.         //獲得隊列中的記錄總數(shù) 
      20.         $count=$Redis->count(); 
      21.         dump($count); 
      22.     } 
      23.     /** 
      24.      * 字符串類型 
      25.      * Enter description here ... 
      26.      */ 
      27.     public function string(){ 
      28.             $Redis=new RedisModel(); 
      29.             //field 表示每個key名稱 
      30.             $rows=$Redis->type("string")->field(array("str1","str2"))->select(); 
      31.             dump($rows); 
      32.     } 
      33.     /** 
      34.      * HASH類型 
      35.      * Enter description here ... 
      36.      */ 
      37.     public function hash(){ 
      38.             $Redis=new RedisModel("h9"); 
      39.             //默認顯示所有HASH字段,可以通過field連慣操作限制 
      40.             $rows=$Redis->type("hash")->field(array("field1"))->select(); 
      41.             dump($rows); 
      42.             //統(tǒng)計總記錄 
      43.             $count=$Redis->type("hash")->count(); 
      44.             dump($count);        
      45.     } 
      46.     /** 
      47.      * 集合類型 
      48.      * Enter description here ... 
      49.      */ 
      50.     public function sets(){ 
      51.             $Redis=new RedisModel(); 
      52.             $arr=array
      53.             "s3","s4" 
      54.             ); 
      55.        $rows=$Redis->type("sets")->field($arr)->where("sinterstore")->select();//求交集 
      56.           dump($rows); 
      57.           $rows=$Redis->type("sets")->field($arr)->where("sunion")->select();//求并集 
      58.           dump($rows); 
      59.           $rows=$Redis->type("sets")->field($arr)->where("sdiff")->select();//求差集 
      60.           dump($rows); 
      61.           $Redis=new RedisModel("s3"); 
      62.           $rows=$Redis->type("sets")->select(); //返回單個集合列表中的所有成員 
      63.           dump($rows); 
      64.           //統(tǒng)計記錄 
      65.           $Redis=new RedisModel("s3"); 
      66.           $count=$Redis->type("sets")->count();  
      67.           dump($count);      
      68.     } 
      69.     /** 
      70.      * 有序集合 
      71.      * Enter description here ... 
      72.      */ 
      73.     public function zset(){  
      74.         $Redis=new RedisModel("z2");  
      75.         //默認顯示0到20      
      76.         $data=$Redis->type("zset")->limit("0,-1")->select(); 
      77.         dump($data); 
      78.         //使用zRevRange顯示數(shù)據(jù),數(shù)組第2個參數(shù)為true時顯示排序號 
      79.          $data=$Redis->type("zset")->limit("0,-1")->order(array("zRevRange",true))->select(); 
      80.         dump($data); 
      81.         //不設置limit時,將統(tǒng)計所有記錄 
      82.         $count=$Redis->type("zset")->limit("0,1")->count(); 
      83.         dump($count); 
      84.          
      85.     } 
      1. <?php  
      2. // redis查詢數(shù)據(jù)  
      3. class IndexAction extends Action {  
      4.     public function page(){  
      5.         $this->display();  
      6.     }  
      7.     /**  
      8.      * 列表類型,默認類型  
      9.      * Enter description here ...  
      10.      */  
      11.     public function lists(){  
      12.         //dump(C("REDIS_HOST"));   
      13.         $Redis=new RedisModel("list1");  
      14.         $field=array(  
      15.             "nmae","age","pro"  
      16.         );  
      17.         $data=$Redis->field($field)->select();  
      18.         dump($data);  
      19.         //獲得隊列中的記錄總數(shù)  
      20.         $count=$Redis->count();  
      21.         dump($count);  
      22.     }  
      23.     /**  
      24.      * 字符串類型  
      25.      * Enter description here ...  
      26.      */  
      27.     public function string(){  
      28.             $Redis=new RedisModel();  
      29.             //field 表示每個key名稱  
      30.             $rows=$Redis->type("string")->field(array("str1","str2"))->select();  
      31.             dump($rows);  
      32.     }  
      33.     /**  
      34.      * HASH類型  
      35.      * Enter description here ...  
      36.      */  
      37.     public function hash(){  
      38.             $Redis=new RedisModel("h9");  
      39.             //默認顯示所有HASH字段,可以通過field連慣操作限制  
      40.             $rows=$Redis->type("hash")->field(array("field1"))->select();  
      41.             dump($rows);  
      42.             //統(tǒng)計總記錄  
      43.             $count=$Redis->type("hash")->count();  
      44.             dump($count);         
      45.     }  
      46.     /**  
      47.      * 集合類型  
      48.      * Enter description here ...  
      49.      */  
      50.     public function sets(){  
      51.             $Redis=new RedisModel();  
      52.             $arr=array(  
      53.             "s3","s4"  
      54.             );  
      55.        $rows=$Redis->type("sets")->field($arr)->where("sinterstore")->select();//求交集  
      56.           dump($rows);  
      57.           $rows=$Redis->type("sets")->field($arr)->where("sunion")->select();//求并集  
      58.           dump($rows);  
      59.           $rows=$Redis->type("sets")->field($arr)->where("sdiff")->select();//求差集  
      60.           dump($rows);  
      61.           $Redis=new RedisModel("s3");  
      62.           $rows=$Redis->type("sets")->select(); //返回單個集合列表中的所有成員  
      63.           dump($rows);  
      64.           //統(tǒng)計記錄  
      65.           $Redis=new RedisModel("s3");  
      66.           $count=$Redis->type("sets")->count();   
      67.           dump($count);       
      68.     }  
      69.     /**  
      70.      * 有序集合  
      71.      * Enter description here ...  
      72.      */  
      73.     public function zset(){   
      74.         $Redis=new RedisModel("z2");   
      75.         //默認顯示0到20       
      76.         $data=$Redis->type("zset")->limit("0,-1")->select();  
      77.         dump($data);  
      78.         //使用zRevRange顯示數(shù)據(jù),數(shù)組第2個參數(shù)為true時顯示排序號  
      79.          $data=$Redis->type("zset")->limit("0,-1")->order(array("zRevRange",true))->select();  
      80.         dump($data);  
      81.         //不設置limit時,將統(tǒng)計所有記錄  
      82.         $count=$Redis->type("zset")->limit("0,1")->count();  
      83.         dump($count);  
      84.           
      85.     }  
      86. }  

      3、刪除數(shù)據(jù)

      1. <?php 
      2. /** 
      3. * Redis刪除數(shù)據(jù) 
      4. * Enter description here ... 
      5. * @author Administrator 
      6. */ 
      7. class DeleteAction extends Action{ 
      8.     /** 
      9.      * list類型 
      10.      * Enter description here ... 
      11.      */ 
      12.     public function lists(){ 
      13.         $Redis=new RedisModel("mylist"); 
      14.             //根據(jù)索引號,刪除指定的list元素          
      15.         echo $Redis->where(3)->delete(); 
      16.         //ltrim區(qū)間批量刪除,保留4~5之間的記錄 
      17. echo $Redis->type("list")->where(array("4","5"))->delete("ltrim");  
      18.         //lpop單條順序彈出     
      19. echo $Redis->type("list")->delete("lpop");  
      20.          
      21.     } 
      22.      /** 
      23.      * 字符串類型 
      24.      * Enter description here ... 
      25.      */ 
      26.     public function string(){ 
      27.            $Redis=new RedisModel(); 
      28.            //直接刪除key,這各方式適用于所有數(shù)據(jù)類型 
      29.            echo $Redis->type("string")->field(array("str1","str2"))->delete(); 
      30.     } 
      31.     /** 
      32.      * HASH類型 
      33.      * Enter description here ... 
      34.      */ 
      35.     public function hash(){ 
      36.         $Redis=new RedisModel("user:1");         
      37.              //刪除指定hash中的指定字段(field),不支持批量刪除 
      38.              echo $Redis->type("hash")->where("field1")->delete();  
      39.      
      40.     } 
      41.      /** 
      42.      * 集合類型 
      43.      * Enter description here ... 
      44.      */ 
      45.     public function sets(){ 
      46.              $Redis=new RedisModel("s1"); 
      47.         //刪除sets:1集合中名為age的value     
      48.         echo $Redis->type("sets")->where("age")->delete(); 
      49.     } 
      50.     /** 
      51.      * 有序集合 
      52.      * Enter description here ... 
      53.      */ 
      54.     public function zset(){  
      55.         $Redis=new RedisModel("z1"); 
      56.         //根據(jù)集合元素value進行刪除 
      57.         echo $Redis->type("zset")->where("two")->delete();  
      58.         //根據(jù)排序號進行區(qū)間批量刪除,保留2~3之間的記錄 
      59.         echo $Redis->type("zset")->where(array("1","4"))->delete("zremRangeByScore");  
      60.         //根據(jù)索引號進行區(qū)間批量刪除,保留2~3之間的記錄 
      61.         echo $Redis->type("zset")->where(array("1","3"))->delete("zRemRangeByRank");  
      62.     } 
      63. ?> 
      1. <?php  
      2. /**  
      3.  * Redis刪除數(shù)據(jù)  
      4.  * Enter description here ...  
      5.  * @author Administrator  
      6.  *  
      7.  */  
      8. class DeleteAction extends Action{  
      9.     /**  
      10.      * list類型  
      11.      * Enter description here ...  
      12.      */  
      13.     public function lists(){  
      14.         $Redis=new RedisModel("mylist");  
      15.             //根據(jù)索引號,刪除指定的list元素           
      16.         echo $Redis->where(3)->delete();  
      17.         //ltrim區(qū)間批量刪除,保留4~5之間的記錄  
      18. echo $Redis->type("list")->where(array("4","5"))->delete("ltrim");   
      19.         //lpop單條順序彈出      
      20. echo $Redis->type("list")->delete("lpop");   
      21.           
      22.     }  
      23.      /**  
      24.      * 字符串類型  
      25.      * Enter description here ...  
      26.      */  
      27.     public function string(){  
      28.            $Redis=new RedisModel();  
      29.            //直接刪除key,這各方式適用于所有數(shù)據(jù)類型  
      30.            echo $Redis->type("string")->field(array("str1","str2"))->delete();  
      31.     }  
      32.     /**  
      33.      * HASH類型  
      34.      * Enter description here ...  
      35.      */  
      36.     public function hash(){  
      37.         $Redis=new RedisModel("user:1");          
      38.              //刪除指定hash中的指定字段(field),不支持批量刪除  
      39.              echo $Redis->type("hash")->where("field1")->delete();   
      40.       
      41.     }  
      42.      /**  
      43.      * 集合類型  
      44.      * Enter description here ...  
      45.      */  
      46.     public function sets(){  
      47.              $Redis=new RedisModel("s1");  
      48.         //刪除sets:1集合中名為age的value      
      49.         echo $Redis->type("sets")->where("age")->delete();  
      50.     }  
      51.     /**  
      52.      * 有序集合  
      53.      * Enter description here ...  
      54.      */  
      55.     public function zset(){   
      56.         $Redis=new RedisModel("z1");  
      57.         //根據(jù)集合元素value進行刪除  
      58.         echo $Redis->type("zset")->where("two")->delete();   
      59.         //根據(jù)排序號進行區(qū)間批量刪除,保留2~3之間的記錄  
      60.         echo $Redis->type("zset")->where(array("1","4"))->delete("zremRangeByScore");   
      61.         //根據(jù)索引號進行區(qū)間批量刪除,保留2~3之間的記錄  
      62.         echo $Redis->type("zset")->where(array("1","3"))->delete("zRemRangeByRank");   
      63.     }  
      64. }  
      65. ?> 

        本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內(nèi)容,請點擊一鍵舉報。
        轉藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多