当我在Redis的键中设置布尔值(
我正在使用Ruby。
以下是示例设置:
true
)时,该值会被强制转换为字符串("true"
)。而对于memcached,我得到的是我放入的值。但是在Redis中,似乎所有的值都被字符串化了。我找不到任何关于如何解决这个布尔问题的文档。没有特殊的boolean_set方法或boolean选项。我正在使用Ruby。
以下是示例设置:
require 'redis'
@redis = Redis.new
在IRB中运行:
irb(main):034:0> bool = true
=> true
irb(main):035:0> bool
=> true
irb(main):036:0> @redis.set("example", bool)
=> "OK"
irb(main):037:0> @redis.get("example")
=> "true"
irb(main):038:0> @redis.get("example") == bool
=> false