手记

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语言写的驱动包


<?phprequire_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

0人推荐
随时随地看视频
慕课网APP