問題描述
我正在將 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 的鍵的操作的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!