The online unified chat and push system redis version 2.8.6 has been running well for nearly a year. The reason why we tested redis3.0 is because 3.0 has added many new features compared to 2.8:
redis cluster - a distributed redis implementation
New "embedded string" object encoding results, fewer cache misses, and significant speed improvements under specific workloads
aof child -> parent final data transmission Minimize latency by "last write" during the aof rewrite process
Significantly improve the lru approximation algorithm for key erasure
wait command blocks waiting for the write operation to be transmitted to the specified number of slave nodes
migrate Connection caching, greatly improving the speed of key transplantation
migarte New parameters copy and replace
client pause command: stop processing client requests within the specified time
bitcount performance improvement
config set accepts different units Memory value, such as "config set maxmemory 1gb".
Small adjustment of redis log format for the role of reaction instance (master/slave)
incr performance improvement
Keep exploring technology while you are young Heart!
Start the installation
1. Install dependency packages
Copy the code The code is as follows:
[root@localhost ~]# yum install gcc gcc-c kernel-devel automake autoconf libtool make wget tcl vim ruby rubygems unzip php-devel git -y
2. Install redis server
No need to ./configure
, no need to make install
just compile it
[root@localhost ~]# wget http://download.redis.io/releases/redis-3.0.6.tar.gz [root@localhost ~]# tar xzf redis-3.0.6.tar.gz [root@localhost ~]# cd redis-3.0.6 [root@localhost redis-3.0.6]# make [root@localhost redis-3.0.6]# src/redis-server
3. Use redis client to test
[root@localhost redis-3.0.6]# src/redis-cli 127.0.0.1:6379> set key val ok 127.0.0.1:6379> get key "val" 127.0.0.1:6379> del key (integer) 1 127.0.0.1:6379> exists key (integer) 0
4. Install phpredis to facilitate the use of php to operate redis
phpredis download address:
[root@localhost ~]# unzip phpredis-develop.zip [root@localhost ~]# cd phpredis-develop [root@localhost phpredis-develop]# phpize [root@localhost phpredis-develop]# ./configure [root@localhost phpredis-develop]# make && make install
Tips: installing shared extensions: /usr /lib64/php/modules/
vi /etc/php.ini
Join
extension=redis.so
Restart apache
service httpd restart
##5. PHP connection redis code test
<?php $redis = new redis(); $redis->connect('localhost', 6379); $rs = $redis->set('test',"11111111111"); $result = $redis->get('test'); var_dump($result);//结果:string(11) "11111111111" $redis->delete('test'); $redis->sadd("test","111");//往test集合中添加一个元素 111 $redis->sadd("test","222"); $redis->sadd("test","333"); $redis->sadd("test1","111"); $redis->sadd("test1","444"); //将集合test和集合test1的并集存进一个新集合new var_dump($redis->sinterstore('new',"test","test1")); //结果:int(1) //返回集合元素 var_dump($redis->smembers('new')); //结果:array(1) { [0]=> string(3) "111" } ?>
The above is the detailed content of How to install Redis3.0 in CentOS environment. For more information, please follow other related articles on the PHP Chinese website!