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~