Redis.set不保存带下划线或连字符的键,Redis.get返回nil

时间:2015-10-05 21:19:13

标签: ruby-on-rails redis

正如标题所示,我使用的是Redis gem,这里是输出:

2.2.2 :011 > $redis = Redis.connect
 => #<Redis client v3.2.1 for redis://127.0.0.1:6379/0> 
2.2.2 :012 > $redis.set("max-tag-id", "hi")
 => "OK" 
2.2.2 :013 > $redis.get("max-tax-id")
 => nil 
2.2.2 :014 > $redis.set("max_tag_id", "hi")
 => "OK" 
2.2.2 :015 > $redis.get("max_tax_id")
 => nil 
2.2.2 :016 > $redis.set("maxtagid", "hi")
 => "OK" 
2.2.2 :018 > $redis.get("maxtagid")
 => "hi" 

为什么这???

1 个答案:

答案 0 :(得分:0)

每当你得到nil你得到“max_tax_id”时你就永远不会设置那个键。你设置“max_tag_id”