Redis installation Download, extractandcompileRediswith: drawing $ cdredis-3.0.4 $ makeThebinariesthataren... A: redis installation
Download, extract and compile Redis:
$ Wget http://download.redis.io/releases/redis-3.0.4.tar.gz
$ Tar xzf redis-3.0.4.tar.gz
$ Redis-3.0.4 cd
$ Make
The binaries that are now compiled are available in the src directory. Run Redis:
$ 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
II. php extension:
More versions: http://pecl.php.net/package/redis
Wget http://pecl.php.net/get/redis-2.2.5.tgz
# Decompress
Tar zxvf redis-2.2.5.tgz
# Enter the installation directory
Cd redis-2.2.5
/Usr/local/php/bin/phpize
# Configuration
./Configure -- with-php-config =/usr/local/php/bin/php-config
# Compile and install
Make & make install
After the installation is complete, 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.
Small example of redis:
$ Redis = new redis ();
$ Test = $ redis-> connect ('2017. 0.0.1 ', 127 );
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 for this is that the company uses Alibaba's RDS and occasionally gets stuck when concurrency is high. The CPU is directly 6000. RDS is 12 GB of memory, with a maximum IOPS of 2000 and a maximum connection count, in fact, we are far from reaching this number, so we want to create a redis queue for fun and put some things that do not need to be executed in real time in the queue for execution. I wanted to directly execute the queue after the data is saved for several minutes. I didn't think of a good method. I had to write a script in linux and run it once every few minutes, this is not very intelligent. there are some waste of resources. do you have any good ideas? Storm of mind ~