WRONGTYPE 针对持有错误类型值 Laravel 的键的操作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35036907/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 13:07:32  来源:igfitidea点击:

WRONGTYPE Operation against a key holding the wrong kind of value Laravel

laravelredis

提问by Vipin Singh

Hi I am using Laravel with Redis .When I am trying to access a key by get method then get following error "WRONGTYPE Operation against a key holding the wrong kind of value"

嗨,我正在将 Laravel 与 Redis 一起使用。当我尝试通过 get 方法访问密钥时,出现以下错误“针对持有错误类型值的密钥的错误类型操作”

I am using following code to access the key value -

我正在使用以下代码访问键值 -

Route::get('/', function () {

    //$redis = app()->make("redis");
    $redis = Redis::connection();

    return $redis->get("doctor:8a772886-e7b2-442a-a0d5-621307510c6a");

});

回答by Dhananjay Kashyap

Could you please try this code sample and see if it works for you.

你能试试这个代码示例,看看它是否适合你。

return $redis->HGETALL("doctor:8a772886-e7b2-442a-a0d5-621307510c6a");