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

curl で redis のキーの一覧を取得

Last updated at Posted at 2018-05-20

ローカルの Redis サーバーにアクセスする例です。

次のようなコマンドのスクリプトを用意します。

command.txt
keys *

quit
.

curl で実行した例

$ curl -s telnet://localhost:6379 < command.txt 
*8
$5
t1857
$5
t1851
$5
t1858
$5
t1854
$5
t1853
$5
t1855
$5
t1859
$5
t1852
+OK

redis-cli で実行した例

$ redis-cli < command.txt 
1) "t1857"
2) "t1851"
3) "t1858"
4) "t1854"
5) "t1853"
6) "t1855"
7) "t1859"
8) "t1852"

次のコマンドでもキーの一覧が取得できます。

redis-cli --scan

確認したバージョン

$ curl --version
curl 8.9.1 (x86_64-pc-linux-gnu) libcurl/8.9.1 OpenSSL/3.3.1 zlib/1.3.1 brotli/1.1.0 zstd/1.5.6 libidn2/2.3.7 libpsl/0.21.2 libssh2/1.11.0 nghttp2/1.62.1 librtmp/2.3 OpenLDAP/2.6.8
Release-Date: 2024-07-31, security patched: 8.9.1-2ubuntu2.2

$ redis-cli --version
redis-cli 7.0.15
1
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
1
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?