- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
问题很简单,就像我想在管道模式下使用文件和 redis-cli 在 redis 中进行大量插入一样。 Redis 文档在此处对此进行了解释:http://redis.io/topics/mass-insert
我的文件只包含这个命令:
HMSET client:1 name "Michael"
当我在我的 shell (Ubuntu Linux) 中尝试时:
cat data.txt | redis-cli --pipe
我收到这个错误:
ERR unknown command '$4'
ERR wrong number of arguments for 'echo' command
ERR unknown command '$20'
我看到其他用户也有同样的问题 ( How to use Redis mass insertion? ) 但我还没有找到好的解决方案。
如有任何帮助,我们将不胜感激。
更新:解决方案
最后,对我来说最好的选择是使用用 Python 开发的 redis 客户端。这是一个非常直接的解决方案,重点是我们不需要直接使用/编写 redis 协议(protocol)。
我选择 redis-py 客户端 ( https://github.com/andymccurdy/redis-py )。安装后,您可以在 python 脚本中导入它的功能。这是我的脚本如何完成工作的示例:
import redis
# Connection to 0 database (default in redis)
r = redis.Redis(host="localhost",db=0)
# inserting client hashmaps
r.hmset('client:1', {'name':'John', 'company':'Microsoft'})
r.hmset('client:2', {'name':'James', 'company':'Apple'})
# inserting a list of domains for client 1
r.rpush('client:1:domains','www.microsoft.com','www.msn.com')
#to print values in stdout
print(r.hgetall('client:1'))
最佳答案
您的输入文件应该包含 Redis 协议(protocol),而不是文本命令。
请在此处查看示例:Redis Mass Insertion
这里描述了 Redis 协议(protocol): http://redis.io/topics/protocol
关于python - Redis 批量插入不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18872380/
今天有小伙伴给我留言问到,try{...}catch(){...}是什么意思?它用来干什么? 简单的说 他们是用来捕获异常的 下面我们通过一个例子来详细讲解下
我正在努力提高网站的可访问性,但我不知道如何在页脚中标记社交媒体链接列表。这些链接指向我在 facecook、twitter 等上的帐户。我不想用 role="navigation" 标记这些链接,因
说现在是 6 点,我有一个 Timer 并在 10 点安排了一个 TimerTask。之后,System DateTime 被其他服务(例如 ntp)调整为 9 点钟。我仍然希望我的 TimerTas
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我就废话不多说了,大家还是直接看代码吧~ ? 1
Maven系列1 1.什么是Maven? Maven是一个项目管理工具,它包含了一个对象模型。一组标准集合,一个依赖管理系统。和用来运行定义在生命周期阶段中插件目标和逻辑。 核心功能 Mav
我是一名优秀的程序员,十分优秀!