我必须提取80万行(它是dev环境,实际上可以是1行,甚至1.5行)。第二步是将这些内容作为序列化数据插入到Redis缓存中。
我的问题是:
你有过大型数据操作的经验吗?我不知道该怎么处理。
请:)
诚挚的问候。
发布于 2016-06-13 08:40:18
在您的示例中,我会将您生成的内容作为redis SET命令放在文件中,然后使用redis-cli -管道执行该文件,在下面的链接中读取您的redis混乱插入数据文件的外观:
<?php
while ($line = mysqli_fetch_assoc($result)) {
$data['data'] = $line['somekey']; // here generate the desired data
$data['key'] = 'thekey'; // make the data key
$redisCommnand = 'SET '.$data['key'].' '.$data['data']; // here you create the redis insert command line someDataKey
file_put_contents('/tmp/data.txt', $redisCommand, FILE_APPEND);// appending the command to redis command file
}
// exec command to run the file
exec('cat data.txt | redis-cli --pipe');
// consider removing the data.txt file
// unlink('/tmp/data.txt');https://stackoverflow.com/questions/37242362
复制相似问题