PHPredis缓存数据库(成功)[数据库教程]

database


<?php


$redis = new Redis();
$redis->connect( ‘127.0.0.1‘, 6379 )or die( "could net connect redis server" );

 

$connect = mysql_connect( ‘127.0.0.1‘, ‘root‘, ‘12345678‘ );
mysql_set_charset( ‘utf8‘, $connect );
mysql_select_db( table );

$query = "select * from user1 limit 3";

$result = mysql_query( $query );

while ( $row = mysql_fetch_assoc( $result ) ) {

 


json_encode( $row, JSON_UNESCAPED_UNICODE );
$id= $row[‘id‘];

$redis->rpush( $id, $row[‘id‘] );
$redis->rpush( $id, $row[‘age‘] );
$redis->rpush( $id, $row[‘name‘] );
$redis->rpush( $id, $row[‘detail‘] );
$data = $redis->lrange( $id ,0,-1);

 

echo "number is <b><font color=#FF0000>$id</font></b>";

echo "<br>";

print_r($data);
// echo "detail is <b><font color=#FF0000>$data</font></b>";

echo "<br>";


}

?>

 

PHP redis 缓存数据库(成功)

原文:https://www.cnblogs.com/summerGraden/p/13273974.html

以上是 PHPredis缓存数据库(成功)[数据库教程] 的全部内容, 来源链接: utcz.com/z/534514.html

回到顶部