0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

HRANDFIELDを使うとき“ERR value is not an integer or out of range”が出る

Last updated at Posted at 2023-02-17

こんにちは、tdzzの初投稿です。

エラーの例

127.0.0.1:3031[10]> hrandfield text withvalues
(error) ERR value is not an integer or out of range

解決策

redisの公式サイトを参照すると...
HRANDFIELD key [count [WITHVALUES]]
構文はこう使うべき。

つまり、withvaluesオプションを使うには、countを指定しなければなりません。

127.0.0.1:3031[10]> hrandfield text 1 withvalues
1) "19485"
2) "some text"

こうしたら、ちゃんと動いてますね。

[ ]とは、オプショナルの意味ですね。[ ]の入れ子構造で、内の子を利用するには、外の子が必要です。countを指定しないと、"withvalues"がcountの値と認識されました。countの値に整数が必要なので、エラーが発生しました。

追記

ちなみに、HRANDFIELDはredis 6.2に新しく導入されたコマンドです。私の場合、aptリポジトリ内のredis-serverバージョンが古い(6.0)。公式サイトでインストール方法を調べましょう。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?