【发布时间】:2014-07-28 08:15:06
【问题描述】:
我需要设计一个程序来循环遍历 1 亿个关键字,调用 Web 服务 (http://example.com/service.aspx?keyword=xxxx) 并将结果作为 JSON 输出保存到 redis 中。
我的想法是首先将所有关键字(这是Web服务的输入)大量插入redis。
之后,我将使用rolling-curl 编写一个PHP 脚本,该脚本将从Redis 读取并用两件事更新它:标志和结果。 flag key 将用于跟踪更新的记录,后者将用于存储 JSON 字符串,如下所示:
{
"keyword": "keyword_1",
"flag": 1,
"output": "result": [
{
"ID": "21",
"field1": "some text",
"field2": "another text"
},
{
"ID": "150",
"field1": "some text",
"field2": "another text"
},
{
"ID": "255",
"field1": "some text",
"field2": "another text"
}
]
}
问题:
1) 就完成这项任务的预期时间而言,这是最好和最有效的方法吗?
2) 使用这种数据结构,我可以搜索我的redis并使用field1或field2找到关键字吗?如果没有,如何使用redis来实现?
谢谢
【问题讨论】:
-
一亿!祝你好运
标签: php performance curl redis nosql