如果密钥有空格,如何使用HDEL删除密钥

时间:2019-06-24 06:12:38

标签: ruby-on-rails redis redis-cli

我正在使用Ruby 2.5.1,并尝试使用HDEL从Redis中删除密钥。但这对空格键无效。我可以使用redis-cli中的引号删除,但我需要编写代码以删除带空格的键。

样品值

  

[“播放组_1”,“ {\” id \“:\” 1 \“,\”名称\“:\”播放组\“}”]

删除在redis-cli中不起作用(如果未在其中传递单引号),

    $(document).ready(function(){
    $(document).scroll(function(){
    var postionTop = $(document).scrollTop();
    console.log(postionTop);
    if((postionTop >=600)){
        $('.chart').easyPieChart({
            animate: 2000,
       });
    };
  });
});

删除工作在redis-cli中(如果在其中传递单引号),

127.0.0.1:6379> HDEL development_groups play group_1
(integer) 0

Ruby代码,

  

redis.hdel(索引,键)

如何使用HDEL删除带空格的键?

1 个答案:

答案 0 :(得分:0)

尝试使用to_s选项

i.e)key.to_s

相关问题