|
|
@ -13,7 +13,9 @@ function getRedisData($ip) { // 查询Redis,不存在返回NULL |
|
|
|
$redis = new Redis(); |
|
|
|
global $redisSetting; |
|
|
|
$redis->connect($redisSetting['host'], $redisSetting['port']); |
|
|
|
$redis->auth($redisSetting['passwd']); |
|
|
|
if ($redisSetting['passwd'] != '') { |
|
|
|
$redis->auth($redisSetting['passwd']); |
|
|
|
} |
|
|
|
$redisKey = $redisSetting['prefix'] . $ip; |
|
|
|
$redisValue = $redis->exists($redisKey) ? $redis->get($redisKey) : NULL; |
|
|
|
return $redisValue; |
|
|
@ -23,7 +25,9 @@ function setRedisData($ip, $data) { // 写入信息到Redis |
|
|
|
$redis = new Redis(); |
|
|
|
global $redisSetting; |
|
|
|
$redis->connect($redisSetting['host'], $redisSetting['port']); |
|
|
|
$redis->auth($redisSetting['passwd']); |
|
|
|
if ($redisSetting['passwd'] != '') { |
|
|
|
$redis->auth($redisSetting['passwd']); |
|
|
|
} |
|
|
|
$redisKey = $redisSetting['prefix'] . $ip; |
|
|
|
$redis->set($redisKey, $data); // 写入数据库 |
|
|
|
$redis->pexpire($redisKey, $redisSetting['cache_time']); // 设置过期时间 |
|
|
|