0
1

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 3 years have passed since last update.

【Redis】redis-cliの備忘録

Last updated at Posted at 2021-01-21

はじめに

Redisのコマンドや特徴などについてのマイ備忘録
随時更新する

基本操作

大文字が予約語

# 起動
$ redis-cli

# DB番号選択
$ SELECT 1

# key, valueをセット
$ SET key value

# key一覧取得
$ KEYS *

# value取得
$ GET key_name

KEYについて

key名変更

$ RENAME 古いkey名 新しいkey名

正規表現

Redisで使える正規表現は以下のみ

  • []
    • カッコ内のいずれかの文字1つ
  • *
    • 任意の文字列
  • ?
    • 任意の1文字

使用例

# 全てのKey取得
$ keys *

# 数字で始まるkey取得
$ keys [0-9]*

マルチバイト文字列

普通に起動すると、マルチバイト文字列が文字化けすることがある

$ redis-cli

# ここでのvalueの中身は適当
$ get hoge
"\xe3\x81"

この場合、以下のようにrawオプションをつけると良い

$ redis-cli --raw
$ get hoge
"ほげ"

参考
redis-cliでマルチバイト文字列が文字化けする時はrawオプションを使う - Qiita

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?