首页 > 解决方案 > 我的 redis “ERR 未知命令 'HSTRLEN'”怎么了?

问题描述

1)127.0.0.1:6379> HMSET myhash f1 helloword f2 99 f3 -256
OK
127.0.0.1:6379> HGETALL myhash
2) "f1"
3) "helloword"
4) "f2"
5) "99"
6) "f3"
7) "-256"
127.0.0.1:6379> HSTRLEN myhash f1
(error) ERR unknown command 'HSTRLEN'
127.0.0.1:6379> 

但这是官方的例子,HSTRLEN key field what's wearg??

标签: hashredis

解决方案


在这里发现自己,发现这是一个版本问题:

https://redis.io/commands/hstrlen 自 3.2.0 起可用。

在 Ubuntu 16.04 上:

$ redis-server --version
Redis server v=3.0.6

$ sudo apt search redis-server
redis-server/xenial-updates,xenial-security,now 2:3.0.6-1ubuntu0.3 amd64 [installed]

我的解决方案是在 docker 中运行更高版本。


推荐阅读