redis的php驅動兩種方式

方式一、需要生產(開發)環境安裝php得c擴展

案例:

<?php                                                                                                                                     
  
     $redis=new Redis();
     $redis->connect('192.168.1.96','6379');
     $redis->select(1);
 
     $key='wait_bill';
    $result=$redis->hGetAll($key);
 ?>


方式二、源生php語言寫的驅動包

<?php
require_once('./predis/autoload.php');

$redis       = new Predis\Client(['host'=>'192.168.1.96','port'=>6379,'database'=>1,'password'=>null]);


$result=$redis->keys('*');
print_r($result);
?>


附:predis驅動程序

https://packagist.org/packages/predis/predis

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章