php 添加redis扩展(二)
php代码操作redis
1、连接
<?php
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
//查看服务是否运行
echo "Server is running: " . $redis->ping();
?>
输出结果
Connection to server sucessfully
Server is running: PONG
pong 则成功
2、Redis PHP String(字符串) 实例
<?php
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
//设置 redis 字符串数据
$redis->set("tutorial-name", "Redis tutorial");
// 获取存储的数据并输出
echo "Stored string in redis:: " . $redis->get("tutorial-name");
?>
执行脚本,输出结果为:
Connection to server sucessfully
Stored string in redis:: Redis tutorial
3、Redis PHP List(列表) 实例
<?php
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
//存储数据到列表中
$redis->lpush("tutorial-list", "Redis");
$redis->lpush("tutorial-list", "Mongodb");
$redis->lpush("tutorial-list", "Mysql");
// 获取存储的数据并输出
$arList = $redis->lrange("tutorial-list", 0 ,5);
echo "Stored string in redis";
print_r($arList);
?>
执行脚本,输出结果为:
Connection to server sucessfully
Stored string in redis
Redis
Mongodb
Mysql
4、Redis PHP Keys 实例
<?php
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
// 获取数据并输出
$arList = $redis->keys("*");
echo "Stored keys in redis:: ";
print_r($arList);
?>
执行脚本,输出结果为:
Connection to server sucessfully
Stored string in redis::
tutorial-name
tutorial-list
php 添加redis扩展(二)的更多相关文章
- linux下的redis安装以及php添加redis扩展
一.redis的安装 win版本详见: 下面是linux版本的安装步骤: step1.下载 http://redis.io/download下载完后直接make然后make install,注意sud ...
- lnmp一键安装环境添加redis扩展及作为mysql的缓存
lnmp一键安装环境添加redis扩展 Redis-benchmark 压力测试工具Redis-check-aof 检查redis持久化命令文件的完整性Redis-check-du ...
- php 添加 redis 扩展
Windows下PHP安装Redis扩展的具体步骤方法 下面我们就结合详细的图文,给大家介绍Windows下PHP安装Redis扩展的方法: 首先我们打开这个上面给出的下载链接地址,界面如下: 这里我 ...
- 在ubuntu下面为php添加redis扩展
首先下载redis扩展:wget https://github.com/nicolasff/phpredis/zipball/master -o php-redis.zip 解压缩:unzip php ...
- phpstudy添加redis扩展
操作系统 windows: 直接贴步骤记录下 一. 划重点,运行phpinfo(), 观察第四行 x86 好了记住这个 x86 三. http://pecl.php.net/pa ...
- windows安装redis并为php5.4添加redis扩展
第一步 安装包下载 首先下载php5.4对应版本的php_igbinary.dll,php_redis.dll扩展.(php7以后可不需要php_igbinary.dl这个文件了) 链接:https: ...
- php 添加redis扩展(一)
phpredis 下载地址 http://pan.baidu.com/s/1dFFK0gh 提取码:见评论,(~..)亲身试验,可行 1.下载到目录 cd /usr/local/src 2.解压 t ...
- windows php5.4,5.6,7.X添加redis扩展
首先下载php5.4对应版本的php_igbinary.dll,php_redis.dll扩展. 下载地址:http://download.csdn.net/detail/gejinbao357/ ...
- php 添加redis扩展
我主要是按照http://blog.163.com/fan_xy_qingyuan/blog/static/1889877482014111111283265/ 这篇博客来的,但是这篇博客里只有php ...
随机推荐
- xcrun: error: active developer path ("/Volumes/Xcode/Xcode6-Beta.app/Contents/Developer") does not exist, use xcode-select to change
When using MacOS with xcode6.4, i always meet these error: xcrun: error: active developer path (&quo ...
- 一步一步使用sklearn
http://kukuruku.co/hub/python/introduction-to-machine-learning-with-python-andscikit-learn Hello, %u ...
- 平衡二叉树(Balanced Binary Tree)
平衡二叉树(Balanced Binary Tree)/AVL树:
- C++STL库之set的用法
/*set意为集合,是一个内部自动排序不含重复元素的容器*/#include<stdio.h>#include<set>using namespace std;int main ...
- CSS3详解:transform
CSS3 transform是什么? transform的含义是:改变,使…变形:转换 CSS3 transform都有哪些常用属性? transform的属性包括:rotate() / skew() ...
- 希赛网 > 问答 > 数据库 > MySQL数据库 > MySQL的管理与维护 > MySql开启远程用户登录GRANTALLPRIVILEGESON*.*TO'root'@'%'I MySql开启远程用户登录GRANTALLPRIVILEGESON*.*TO'root'@'%'I
MySql开启远程用户登录 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'huawei' WITH GRANT OPTION; FL ...
- Swiper说明及API手册说明
最近使用Swipe.js,发现中文的资料很少,试着翻译了一下.能力有限,翻译难免错漏,欢迎指出,多谢! 翻译自:http://www.idangero.us/sliders/swiper/api.ph ...
- C++@sublime GDB调试
正文转自:http://www.cppblog.com/lucency/archive/2012/08/09/59214.html 之前在网上搜索了好久使用sublime调试C和C++的文章,但是徒劳 ...
- 防止 SQL 注入的方法(摘抄)
——选自<深入Ajax : 架构与最佳实践 = Advanced Ajax : architecture and best practices/ (美)Shawn M.Lauriat著:张过,宋 ...
- linux下删除所有.svn目录
linux下删除所有.svn目录方法为 find . -type d -name ".svn"|xargs rm -rf 或者 find . -type d -i ...