1.Redis的相关介绍:

定义:

redis是一个key-value存储系统。和Memcached类似,它支持存储的value类型相对更多,包括string(字符串)、list(链表)、set(集合)、zset(sorted set --有序集合)和hash(哈希类型)。这些数据类型都支持push/pop、add/remove及取交集并集和差集及更丰富的操作,而且这些操作都是原子性的。在此基础上,redis支持各种不同方式的排序。与memcached一样,为了保证效率,数据都是缓存在内存中。区别的是redis会周期性的把更新的数据写入磁盘或者把修改操作写入追加的记录文件,并且在此基础上实现了master-slave(主从)同步。
Redis 是一个高性能的key-value数据库。 redis的出现,很大程度补偿了memcached这类key/value存储的不足,在部 分场合可以对关系数据库起到很好的补充作用。它提供了Java,C/C++,C#,PHP,JavaScript,Perl,Object-C,Python,Ruby,Erlang等客户端,使用很方便。 [1] 
Redis支持主从同步。数据可以从主服务器向任意数量的从服务器上同步,从服务器可以是关联其他从服务器的主服务器。这使得Redis可执行单层树复制。存盘可以有意无意的对数据进行写操作。由于完全实现了发布/订阅机制,使得从数据库在任何地方同步树时,可订阅一个频道并接收主服务器完整的消息发布记录。同步对读取操作的可扩展性和数据冗余很有帮助。
 
性能:
官方的bench-mark数据: [1] 
测试完成了50个并发执行100000个请求。
设置和获取的值是一个256字节字符串。
Linux box是运行Linux 2.6,这是X3320 Xeon 2.5 ghz。
文本执行使用loopback接口(127.0.0.1)。
结果:读的速度是110000次/s,写的速度是81000次/s 。
 
2.源码安装Redis服务:
yum install gcc-c++ -y
#下载redis源码包
wget http://download.redis.io/releases/redis-5.0.7.tar.gz
tar xf redis-5.0.7.tar.gz
cd redis-5.0.7
#redis服务无需进行预编译,但需改一下文件的安装路径
Vim src/Makefile 添加:PREFIX?=/usr/local/redis
make && make install
#或者直接安装:
make PREFIX=/usr/local/redis install
#复制redis.conf配置文件到/usr/local/redis
[root@localhost redis-5.0.7]#cp redis.conf /usr/local/redis #配置redis启动脚本
[root@localhost redis-5.0.7]# ./utils/install_server.sh
Welcome to the redis service installer
This script will help you easily set up a running redis server Please select the redis port for this instance: [6379]
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf] /usr/local/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log] /usr/local/redis/6379.log
Please select the data directory for this instance [/var/lib/redis/6379] /usr/local/redis/6379
Please select the redis executable path [] /usr/local/redis/bin/redis-server
Selected config:
Port : 6379
Config file : /usr/local/redis/6379.conf
Log file : /usr/local/redis/6379.log
Data dir : /usr/local/redis/6379
Executable : /usr/local/redis/bin/redis-server
Cli Executable : /usr/local/redis/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful!
[root@localhost redis-5.0.7]# #设置环境变量
echo "export PATH="/usr/local/redis/bin:PATH"" >>/etc/profile.d/redis.sh
source /etc/profile.d/redis.sh

3.php整合redis连接驱动

下载4.2.0.tar.gz源码包并且解压 /安装
# 源码方式安装php,整合redis:
wget https://github.com/phpredis/phpredis/archive/4.2.0.tar.gz
tar xf 4.2.0.tar.gz
cd phpredis-4.2.0/
/usr/local/php/bin/phpize
./configure  --with-php-config=/usr/local/php/bin/php-config  --enable-redis
make && make install #编辑php.ini配置文件,添加redis模块:
extension=redis.so (在854行上下添加) # yum方式安装php,整合redis:
安装php7.0
yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
yum install yum-utils -y
yum-config-manager --enable remi-php70
yum install php php-fpm php-mysql php-redis -y #PS: 以上两种方式,采取其中一种即可

测试redis模块是否添加成功:

#创建info.php文件测试
vim /usr/local/nginx/html/wordpress/info.php
<?php
phpinfo();
?>

webj界面访问:

#查看php是否成功连接Redis
/usr/local/php/bin/php -m

Redis平台-整合PHP的更多相关文章

  1. Redis+LUA整合使用

    .前言 从本章节开始我们就开始讲解一些 Redis 的扩展应用了,之前讲的主从.哨兵和集群都相当重要,也许小公司用不到集群这么复杂的架构,但是也要了解各知识点的原理,只要了解了原理,无论什么时候是有, ...

  2. SSH框架和Redis的整合(1)

    一个已有的Struts+Spring+Hibernate项目,以前使用MySQL数据库,现在想把Redis也整合进去. 1. 相关Jar文件 下载并导入以下3个Jar文件: commons-pool2 ...

  3. spring和redis的整合

    spring和redis的整合-超越昨天的自己系列(7) 超越昨天的自己系列(7) 扯淡:  最近一直在慢慢多学习各个组件,自己搭建出一些想法.是一个涉猎的过程,慢慢意识到知识是可以融汇贯通,举一反三 ...

  4. 【Spring】17、spring cache 与redis缓存整合

    spring cache,基本能够满足一般应用对缓存的需求,但现实总是很复杂,当你的用户量上去或者性能跟不上,总需要进行扩展,这个时候你或许对其提供的内存缓存不满意了,因为其不支持高可用性,也不具备持 ...

  5. springboot+shiro+redis(单机redis版)整合教程-续(添加动态角色权限控制)

    相关教程: 1. springboot+shiro整合教程 2. springboot+shiro+redis(单机redis版)整合教程 3. springboot+shiro+redis(集群re ...

  6. springboot+shiro+redis(集群redis版)整合教程

    相关教程: 1. springboot+shiro整合教程 2. springboot+shiro+redis(单机redis版)整合教程 3.springboot+shiro+redis(单机red ...

  7. springboot+shiro+redis(单机redis版)整合教程

    相关教程: 1. springboot+shiro整合教程 2. springboot+shiro+redis(集群redis版)整合教程 3.springboot+shiro+redis(单机red ...

  8. Spring Boot + MyBatis + Druid + Redis + Thymeleaf 整合小结

    Spring Boot + MyBatis + Druid + Redis + Thymeleaf 整合小结 这两天闲着没事想利用**Spring Boot**加上阿里的开源数据连接池**Druid* ...

  9. spring与redis简单整合

    项目结构 整合需要的依赖 <dependencies> <dependency> <groupId>org.springframework</groupId& ...

  10. spring和redis的整合-超越昨天的自己系列(7)

    超越昨天的自己系列(7) 扯淡:  最近一直在慢慢多学习各个组件,自己搭建出一些想法.是一个涉猎的过程,慢慢意识到知识是可以融汇贯通,举一反三的,不过前提好像是研究的比较深,有了自己的见解.自认为学习 ...

随机推荐

  1. Hexo博客Next主题阅读次数热度不能读取的问题,报错Counter not initialized! More info at console err msg.

    加入valine在线评论 设置效果: 设置方法: 首先要先去LeanCloud注册一个帐号.然后再创建一个应用. 拿到appid和appkey之后,打开themes/next/_config.yml主 ...

  2. PerfView专题 (第十四篇): 洞察那些 C# 代码中的短命线程

    一:背景 1. 讲故事 这篇文章源自于分析一些疑难dump的思考而产生的灵感,在dump分析中经常要寻找的一个答案就是如何找到死亡线程的生前都做了一些什么?参考如下输出: 0:001> !t T ...

  3. 理解TCP3次握手

    以AB通话为例 A的视角 A给B打电话,进入SYN_SENT B接起电话,A确认后,进入ESTABLISHED B的视角 看到A打过来的电话,接起电话,进入SYN_RCVD 确认对方后,进入ESTAB ...

  4. 【pandas小技巧】--按类型选择列

    本篇介绍的是pandas选择列数据的一个小技巧.之前已经介绍了很多选择列数据的方式,比如loc,iloc函数,按列名称选择,按条件选择等等. 这次介绍的是按照列的数据类型来选择列,按类型选择列可以帮助 ...

  5. 查看Nginx是否启动

    查看Nginx进程 ps -ef | grep nginx 输出如下: root 1036 1 0 Jul15 ? 00:00:00 nginx: master process /www/server ...

  6. pandas 格式化日期

    output_data["ShipDate"] = output_data["ShipDate"].dt.strftime("%Y/%m/%d&quo ...

  7. Vue笔记(一)

    1. Vue.js是什么? 1). 一位华裔前Google工程师(尤雨溪)开发的前端js库 2). 作用: 动态构建用户界面 3). 特点: * 遵循MVVM模式 * 编码简洁, 体积小, 运行效率高 ...

  8. 微信小程序+web数据库的开发实践

    前言 生活中使用微信小程序的场景越来越多,它实现了用户对于应用"触手可及.用完即走"的理想需求.微信小程序的开发难度也低于APP的开发制作,使用它会更便利.低成本.高经济效益. 但 ...

  9. quarkus依赖注入之四:选择注入bean的高级手段

    欢迎访问我的GitHub 这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos 本篇概览 本文是<quarkus依赖注入> ...

  10. js 关于 replace 取值、替换第几个匹配项(两种方式:正则、普通字符串操作)

    〇.前言 在日常开发中,经常遇到针对字符串的替换.截取,知识点比较碎容易混淆,特此总结一下,仅供参考. 一.替换第一个匹配项 字符串替换 let strtest = "0123测试repla ...