WRONGTYPE 针对持有错误类型值 php 的键的操作 [英] WRONGTYPE Operation against a key holding the wrong kind of value php

查看:27
本文介绍了WRONGTYPE 针对持有错误类型值 php 的键的操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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"

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

I am using following code to access the key value -

我使用此代码从 redis 获取数据

i use this code for get data from redis

$values = "l_messages";
$value = $redis->HGETALL($values);
print($value);

推荐答案

Redis 支持 6 种数据类型.您需要知道一个键映射到什么类型的值,至于每个数据类型,检索它的命令是不同的.

Redis supports 6 data types. You need to know what type of value that a key maps to, as for each data type, the command to retrieve it is different.

这里是检索键值的命令:

Here are the commands to retrieve key value:

  • 如果值是字符串类型 ->GET
  • 如果值是哈希类型 ->HGETALL
  • 如果值是列表类型 ->lrange <开始><end>
  • 如果值是集合类型 ->成员
  • 如果值是排序集类型 ->ZRANGEBYSCORE <分钟><max>
  • 如果值是流类型 ->xread count .https://redis.io/commands/xread

使用 TYPE 命令检查一个键的值的类型映射到:

Use the TYPE command to check the type of value a key is mapping to:

  • 输入

这篇关于WRONGTYPE 针对持有错误类型值 php 的键的操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆