Linux installation redis service and php redis extension

巴扎黑
Release: 2016-11-10 09:46:40
Original
1241 people have browsed it

One: redis installation
Download, extract and compile Redis with:

$ wget http://download.redis.io/releases/redis-3.0.4.tar.gz

$ tar xzf redis-3.0.4. tar.gz

$ cd redis-3.0.4

$ make

The binaries that are now compiled are available in the src directory. Run Redis with:

$ src/redis-server

You can interact with Redis using the built-in client:

$ src/redis-cli

redis> set foo bar
OK
redis> get foo
"bar"

More: http://www.redis.io/download

2. PHP extension:
More versions: http://pecl.php.net/package/redis

wget http://pecl.php.net/get/redis-2.2.5.tgz

#Unzip

tar zxvf redis-2.2.5.tgz

#Enter the installation directory

cd redis-2.2.5

/usr/local/php/bin/phpize

#Configure

./configure --with-php -config=/usr/local/php/bin/php-config

#Compile and install

make && make install

After the installation is completed, the following installation path appears
/usr/local/php/lib/php/extensions /no-debug-non-zts-20090626/

Configure php support
#Edit the configuration file and add the following content in the last line

vim /usr/local/php/etc/php.ini

extension="redis. so"

At this time, phpinfo() can see the redis extension.

redis small example:

$redis =new redis();

$test=$redis->connect('127.0.0.1',6379);

var_dump($test);

$result = $redis->set('test',"webyang.net");

var_dump($result);//Result: bool(true)

$result = $redis->get('test' );

var_dump($result);//Result: string(11) "webyang.net"

The reason why we do this is because the company uses Alibaba's RDS. Occasionally, when the concurrency is high, the CPU will freeze. One hundred percent, RDS has 12g of memory, a maximum IOPS of 6000, and a maximum number of links of 2000. In fact, we are far from reaching this number, so we considered setting up a redis queue for fun, and putting some things that do not need to be executed in real time into the queue for execution. I originally wanted to set up the execution queue directly after a few minutes after the data is stored. I didn't think of a good way. I could only write a script in Linux and run it every few minutes. In fact, relatively speaking, this is not very smart and exists. Some resources are wasted. Do you have any good ideas? Looking for brainstorming~


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!