redis installation and parameters

Redis data backup and recovery

Save data and save directory

/bin/redis-cli
127.0.0.1:6379 > SAVE

127.0.0.1:6379 >exit


127.0.0.1:6379> CONFIG GET dir
1) "dir"
2) "/usr/local/redis/data" directory where data is saved


Data recovery

Put the data dump.rdb in the /bin/ directory

service redis restart restarts the redis service

Redis configuration file information

 

daemonize yes run as a daemon

/var/run/redis.pid Default pid storage directory


bind 127.0.0.1 bind host address


View the information command of redis:


http://blog.csdn.net/wangdaoge/article/details/53024129


/usr/local/redis/bin/redis-cli -h 127.0.0.1 -p 6379 info

 

PHP redis module

 

redis as mysql cache

URL:

http://www.cnblogs.com/hellowzd/p/5163782.html


The download address of phpredis:

http://pecl.php.net/get/redis-3.1.3.tgz

tar xf redis-3.1.3.tgz

cd redis-3.1.3

/usr/local/php/bin/phpize

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

make && make install

vim /usr/local/php/lib/php.ini

extension=redis.so

/etc/init.d/php-pfm restart

 

 vim index.php

 

 

<?php
$redis = new Redis();
$redis->connect('127.0.0.1',6379) or die ("could net connect redis server");
$query = "select * from test limit 8";
for ($key = 1; $key < 9; $key++)
{
if (!$redis->get($key))
{
$connect = mysqli_connect('127.0.0.1','root','123');
mysqli_select_db($connect,"mytest");
$result = mysqli_query($connect,$query);
while ($row = mysqli_fetch_assoc($result))
//while ($row = mysqli_fetch_assoc($result))
{
$redis->set($row['id'],$row['name']);
}
$myserver = 'mysql';
break;
}
else
{
$myserver = "redis";
$data[$key] = $redis->get($key);
}
}
echo $myserver;
echo "<br>";


for ($key = 1; $key < 9; $key++)
{
echo "number is <b><font color=#FF0000>$key</font></b>";
echo "<br>";
echo "name is <b><font color=#FF0000>$data[$key]</font></b>";
echo "<br>";
}
?>

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324641430&siteId=291194637