我的第一个redis程序

<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

require '../predis/autoload.php'; //引入redis

$config=array(
   'scheme'=>'tcp',
    'host'=>'192.168.152.128',
    'port'=>6379,
    'password'=>'123123'
);
$redis=new Predis\Client($config);//配置连接

try{
    echo $redis->get('name');
} catch (Exception $ex) {
    echo "Message:{$ex->getMessage()}";//处理非字符串异常
}

$userName=array(
    'user:1:name'=>'Tom',
    'user:2:name'=>'Jack'
);
$redis->mset($userName);

$users= array_keys($userName);
print_r($redis->mget($users));

猜你喜欢

转载自blog.csdn.net/taotaobaobei/article/details/82907940
今日推荐