redis连接php-9527
安装在PHP程序中使用Redis,需要确保我们有Redis的PHP驱动程序和PHP安装设置在机器上。可以查看PHP教程教你如何在机器上安装PHP。现在,让我们来看看一下如何设置Redis的PHP驱动程序。
需要从github上资料库https://github.com/nicolasff/phpredis下载phpredis。下载了它以后,将文件解压缩到phpredis目录。在Ubuntu上安装这个扩展,如下图所示。
cd phpredis
sudo phpize
sudo ./configure
sudo make
sudo make install
现在,复制和粘贴“modules”文件夹的内容复制到PHP扩展目录中,并在php.ini中添加以下几行。
extension = redis.so
现在Redis和PHP安装完成。
连接到Redis服务器
当执行程序时,会产生下面的结果:
Connection to server sucessfully
Server is running: PONG
Redis的PHP字符串实例
当执行程序时,会产生下面的结果:
Connection to server sucessfully
Stored string in redis:: Redis tutorial
Redis的PHP列表示例
当执行程序时,会产生下面的结果:
Connection to server sucessfully
Stored string in redis::
Redis
Mongodb
Mysql
Redis的PHP键例
当执行程序时,会产生下面的结果:
Connection to server sucessfully
Stored string in redis::
tutorial-name
tutorial-list
页:
[1]