// 切换到 5 号库 $redis->select(5); // 获取所有数据 $data = $redis->keys('*'); $datajson=[];

// 输出所有数据 foreach ($data as $key) { $marketData = $redis->hGetAll($key); // arsort($marketData); $marketData = array_map(function ($json) { return json_decode($json, true); }, $marketData);

$marketDatas=[];

//$key => $value
foreach ($marketData as $key1 => $value) {
    $marketDatas+=$value;
}
// 获取最新的 20 条数据
$marketDatas = array_slice($marketDatas, -20);
$datajson[$key]=$marketDatas;

}

PHP 7.3 使用 Redis 获取最新 20 条数据并修复数据丢失问题

原文地址: https://www.cveoy.top/t/topic/obES 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录