ral*_*lph 2 ruby-on-rails redis
我在我的heroku应用程序上尝试redis.我有以下代码config/initializers/redis.rb
uri = URI.parse(ENV["REDISTOGO_URL"])
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
Run Code Online (Sandbox Code Playgroud)
我在控制台中尝试以下操作但收到错误:
irb(main):003:0> REDIS.rpush ('foo','bar')
(irb):3: warning: don't put space before argument parentheses
RuntimeError: -ERR Operation against a key holding the wrong kind of value
Run Code Online (Sandbox Code Playgroud)
小智 11
当您尝试操作例如列表值时,将返回此错误,而键持有另一种类型的值(例如字符串,设置等).要找出存储的值的类型foo,可以使用以下命令:
REDIS.type("foo")
Run Code Online (Sandbox Code Playgroud)
当您对不具有值的键执行RPUSH或LPUSH反对时,将自动创建列表.因此,您必须确保foo不存在或保持此操作的列表值才能工作.
| 归档时间: |
|
| 查看次数: |
12998 次 |
| 最近记录: |