} //如果没有账户密码,就注释掉 /*if ($Redis->auth($user . ":" . $pwd) == false) { die($Redis->getLastError()); }*/ file_put_contents('./redis.json', ''); $it = NULL; /* Initialize our iterator to NULL */ $Redis->setOption(Redis::OPT_SCAN, Redis::SCAN_RETRY); /* retry when we get no keys back */ while ($keys = $Redis->scan($it)) { $out = ''; foreach ($keys as $key) { //echo $Redis->type($key),"\n"; $arr = array(); $type = $Redis->type($key); $expire = $Redis->ttl($key); switch ($type) { case $Redis::REDIS_STRING: //echo "string\n"; $arr['expire'] = $expire; $arr['type'] = $type; $arr['key'] = $key; $arr['val'] = $Redis->get($key); break; case $Redis::REDIS_HASH: //echo "hash\n"; $arr['expire'] = $expire; $arr['type'] = $type; $arr['key'] = $key; $arr['val'] = $Redis->hGetAll($key);