这是我的其他部分的源代码,我可以获取ttl值,但是如果我再次运行该代码,则无法在初始阶段获取ttl值。
$username = 'key';
$redis->set($username , 1);
$ttl = $redis->ttl( $username );
error_log("ttl =============> ".json_encode($ttl));
if($ttl>0){
error_log("ttl =============> ".json_encode($ttl));
$result= array("error"=>"user already blocked".$ttl);
}else {
$limit = 30;
$redis->expire( $username , $limit);
$ttl = $redis->ttl( $username );
$result=array("error"=>"user blocked for one hour, time remaining is ".$ttl);