redis的php驱动两种方式
更新:HHH   时间:2023-1-7


方式一、需要生产(开发)环境安装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

附件:http://down.51cto.com/data/2368127
返回web开发教程...